Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42412

VS 2010 [RESOLVED] Reference a control using a variable

$
0
0
Hi,

I have several controls with an incrementing integer suffix in its name. I'm wondering if it is possible to reference the control using a variable? I can get around this using a dirty select statement but would really like to use a for loop and use the counter value.

For simplicity, I'm trying to get the following to work:

My text box controls are named Test1 and Test2 and would like to set the text along the lines of:

Code:

'I could hardcode this by:
'Test1.Text = "hello"
'Test2.Text = "world"
'but would rather use the below

dim iNum as integer

iNum = 1
Test & iNum.Text = "hello"

iNum = 2
Test & iNum.Text = "world"

Hope that makes sense?

Cheers,
J

Viewing all articles
Browse latest Browse all 42412

Trending Articles