Control array

I have to create an control array (lets say..of textboxes). I don't  know at design time how many (but I know the max).
How do I create a new control when I need it. The set ... =new ...  doesn't work. It only works for creating new forms but not other controls.
AzmodanAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
jetforceConnect With a Mentor Commented:
Just load the textbox just as follows

Load Text1(2)
Text1(2).Left = 100
Text1(2).Visible = True

remember to make sure that you have at least 1 textbox and make sure the index is set to 0
0
 
jetforceCommented:
Ps.  Just change the 2 for the right number, make sure you you dont use the same number again unless you unload the textbox. You dont have to go in increments you could load 3 then 5 and 2 etc.

You can see what indexs have been used by the following code

Dim i As Control

For Each i In Me.Controls
  If i.Name = "Text1" Then
    MsgBox i.Name & "(" & i.Index & ")"
  End If
Next

Hope this helps
0
 
AzmodanAuthor Commented:
thankx
it works
0
 
modderCommented:
Upgraded to "A" as requested in http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20156118

modder
Community Support
0
All Courses

From novice to tech pro — start learning today.