Nobody Nobody - 4 months ago 10
Vb.net Question

How to increase object name in a loop?

I have 1600 textboxes.I want something like this :

Textbox1.Text="1"
Textbox2.Text="2"
Textbox3.Text="3"
Textbox4.Text="4"
...


I know that doesn't work but I need a loop like this:

For i as integer = 0 to 1600
(textbox+i).text=i
Next


I couldn't find anything about this.I don't know is this possible.Any idea ?

Answer
For i as integer = 0 to 1600  
   CType(Me.Controls("Textbox" + i.ToString()), TextBox).Text = i.ToString()
Next 

Hope this will work.

Comments