devxlogo

Create a Control Array at Runtime Instead of Design-time

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.

  1. Start a new VB project.
  2. Place a textbox on the form.
  3. Name the textbox txtarray.
  4. Set the Index property to 0.
  5. Paste the following code into the form and run the program.
  6. 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

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  How Engineering Leaders Spot Weak Proposals

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.