Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Control arrays in run time

Status
Not open for further replies.

OC2

IS-IT--Management
Apr 2, 2001
59
0
0
SG
I was experimenting with different ways I could use Control arrays in run time. One formula I could not work out was, How do I add control arrays in increments of x

The below code illustrates how to add the textbox array 1 at a time during run time.
But I could not work out how to add 2 or 3 at a time. I tried to loop, but each time it said control element(x) doesnt exist.

Could someone help explain the procedure
thx

Private Sub Command1_Click(Index As Integer)

Select Case Index
Dim Boxadd As Integer, Boxremove As Integer, i As Integer

Case 0

Boxadd = txtData().Count

If Boxadd < 5 Then
Load txtData(Boxadd)
txtData(Boxadd).Top = txtData(Boxadd - 1).Top + 400
txtData(Boxadd).Visible = True
End If

Case 1

Unload me

End Select
End Sub
 
to create control arrays at runtime you need to have the intial object created at runtime, so in your case txtData(0) must exist on your form before you can start adding more of them in code
 
Hi Sjravee

txtData(0) does exist on the form.
The code above currently adds 1 text box at a time to a maximum of 5.
What I would like to do is instead of adding the 4 extra boxes ontop of txtdata(0) 1 at a time, but as all 4 at 1 time, or on a variable of 2 at a time etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top