Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Determine Control Name Dynamically?

Determine Control Name Dynamically?

Determine Control Name Dynamically?

Working on a project where I have multiple similarly named controls, Text Boxes in this case, where I want to build the control name in code and then assign the value.

For instance I have text boxes:

And I have the text that needs to go into those text boxes in a 2x2 string array. What I'd like to do is, within a set of loops, have one equation that would function as
TB_A_i_j.Text = Array(i,j)

Of course it doesn't seem to be that easy. Is there some way of doing this, or do I have to brute force it and have multiple IF statements (or other construct)?

Working in the VB portion of Visual Studio 2010.

RE: Determine Control Name Dynamically?

How would one create an array of text boxes? I think it might be possible to define them in code, but is there anyway to set them up in design?

RE: Determine Control Name Dynamically?

Well, that got me looking in the right direction. Apparently the copy and paste method of creating control arrays ended with VB6. In VB2010 (Visual Studio Express 2010) the method that I found that works is in each subroutine where I want to use an array of TB_A_x_x would be to start with


Dim TB_A as TextBox(,)={{TB_A_1_1,TB_A_1_2},{TB_A_2_1,TB_A_2_2}} 

Then I can use a pair of indices to control which text box I want. Too bad VB2010 doesn't have an OPTION BASE 1 option.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close