Solved

Accessing data from several textboxes.

Posted on 2006-06-26
5
168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

729 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