control arrays in vb 2005
Posted on 2006-06-27
In VB 6 or earlier I have used control arrays before. I understand they are not supported anymore in vb 2005.
I have tried to look the workings of it up but still have a problem accessing an individual control by index.
I have 6 textboxes withing a tablelayout. In VB 6 I would have created a control array and accessed the contain like below:
Dim i as integer = 4 ' number comes from some other code
textbox(i).text = "some Text"
How can I do this in vb 2005.
The code below lets me change all of my textboxes but I am struggling if I want to change the text for only one of the textboxes like above.
Private Sub ClearText(ByVal container As Control)
Dim ctrl As Control
For Each ctrl In container.Controls
If TypeOf (ctrl) Is TextBox Then
ctrl.Text = "some text"