Solved

Accessing data from several textboxes.

Posted on 2006-06-26
5
163 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
Comment Utility
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
Comment Utility
(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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

744 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

12 Experts available now in Live!

Get 1:1 Help Now