PDA

View Full Version : Solved: Using Object by calling a variable



Kicker
09-03-2005, 10:54 AM
I have searched the boards, but....

I have over 100 textbox objects on my form. Call them txt0, txt1, txt2, etc...

Depending on the data in a table and how it plays together, various combinations could refer to txt25, etc. The combinations are endless. However, In can easily manipulate them into numbers. What I need to do is refer to a specific textbox. example:

"txt" & str(25) = txt25 which is the textbox I want to use.

How can I create a variable, initialize it to "txt25" and then use it to call the object txt25?

I have tried
dim myObj as new textbox
dim strObj as string

strObj = "txt25"

A little help please
:beerchug:

Killian
09-03-2005, 12:20 PM
lets say you have your number and assign it to variable i
then you could use something like
UserForm1.Controls("txt" & i).SetFocus

Kicker
09-03-2005, 03:22 PM
I knew I could get a reply from this board. thanks a lot, it works.