To create and access the control arrays as though they were created at design time, simply follow these steps and use the code. This example creates an array of text boxes at runtime.
- Start a new VB project.
- Place a textbox on the form.
- Name the textbox txtarray.
- Set the Index property to 0.
- Paste the following code into the form and run the program.
Private Sub Form_Load()Dim i As Integer txtArray(0).text = "0" For i = 1 To 5 Load txtArray(i) With txtArray(i) .Text = i .Visible = True .Top = txtArray(i - 1).Top + 550 End With Next iEnd Sub