i am curious what exactly is a control array?
Printable View
i am curious what exactly is a control array?
Control array is like you put 1 textbox who will have the same name like text1 with a number after it : text1(0).text text1(1).text.
It have many advantage, like you can do some loop :
VB Code:
For i = 0 to ubound(text1) ' Ubound = length of array text1(i).text = "HI" Next i
Array keep order in the form and I think it take less memory but I am not sure.
As the name states, it is an array of controls. It is quite useful; for example if you need to get 10 strings from a user, you can add 10 TextBoxes on a form and do this:
Also, VB has a limit of 255 controls on one form. But a control array counts as only one control.VB Code:
Dim i As Long For i = 0 To txtMyArray.Count - 1 Msgbox "TextBox #" & i & " contained " & txtMyArray(i).Text Next i
I guess it should be:Quote:
Originally posted by DaoK
VB Code:
For i = 0 to ubound(text1) ' Ubound = length of array text1(i).text = "HI" Next i
VB Code:
For i = 0 to text1.ubound ' Ubound = length of array text1(i).text = "HI" Next i
Actually. :)VB Code:
Text1.Count
Actually, it should be .Ubound and have an errorhandler code, in case some of the indexes don't exist. .Count would only return the number of controls there are. ;)
Ubound is for variable sorry!!!