Consulting

Results 1 to 3 of 3

Thread: Solved: Using Object by calling a variable

  1. #1

    Solved: Using Object by calling a variable

    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
    ttfn

    Kicker

  2. #2
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    lets say you have your number and assign it to variable i
    then you could use something like
    [VBA]UserForm1.Controls("txt" & i).SetFocus[/VBA]
    K :-)

  3. #3
    I knew I could get a reply from this board. thanks a lot, it works.
    ttfn

    Kicker

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •