Go Premium for a chance to win a PS4. Enter to Win

x
Solved

# Accessing data from several textboxes.

Posted on 2006-06-26
Medium Priority
170 Views
Hi experts!

I have 81 textboxes in a form in a 9x9-pattern.
They are named TextBoxXY (where XY are the corresponding numbers in the 9x9-patter, for example TextBox11 is the first and TextBox99 is the last).
I need to copy data from theese boxes into an array ( square(1,1) ) but I can't make the coding effective.

As it is now it says:
square(1,1) = TextBox11
square(1,2) = TextBox12
square(1,3) = TextBox13
...
square(9,7) = TextBox97
square(9,8) = TextBox98
square(9,9) = TextBox99

This is not really efficient.
What I would like is some sort code that looks something like this:

for i = 1 to 9
for j = 1 to 9
square(i,j) = TextBoxij
next
next

0
Question by:ElSmisko
• 2
• 2

LVL 66

Expert Comment

ID: 16986962
for i = 1 to 9
for j = 1 to 9
square(i,j) = frm("TextBox" & i & j).Text
next
next
0

LVL 66

Assisted Solution

Jim Horn earned 150 total points
ID: 16987024
(slight correction)

for i = 1 to 9
for j = 1 to 9
square(i,j) = Me("TextBox" & i & j)
next
next
0

Author Comment

ID: 16987143

"Class 'WindowsApplication1.Form1' cannot be indexed because it has no default property."

0

LVL 37

Accepted Solution

Harisha M G earned 300 total points
ID: 16987240
for i = 1 to 9
for j = 1 to 9
square(i,j) = Me.Controls("TextBox" & i & j)
next
next
0

Author Comment

ID: 16987393
Me.Controls("TextBox" & i & j).Text
for it to work, but now it works. =D

Thanks for all your help guys!
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
###### Suggested Courses
Course of the Month10 days, left to enroll