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

x
?
Solved

Accessing data from several textboxes.

Posted on 2006-06-26
5
Medium Priority
?
170 Views
Last Modified: 2010-04-07
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

Thank you for your help!
0
Comment
Question by:ElSmisko
  • 2
  • 2
5 Comments
 
LVL 66

Expert Comment

by:Jim Horn
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

by:Jim Horn
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

by:ElSmisko
ID: 16987143
Thank you for your fast reply!

I tried both your examples but I receive an error-message saying:
"Class 'WindowsApplication1.Form1' cannot be indexed because it has no default property."

I have no idea what that means. Please help.
0
 
LVL 37

Accepted Solution

by:
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

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

Thanks for all your help guys!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question