Solved

Accessing data from several textboxes.

Posted on 2006-06-26
5
164 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 65

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 65

Assisted Solution

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

863 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now