15ctrl Ary
15ctrl Ary
CONTROL ARRAYS
Similar to arrays of variables, you can group a set of controls together as an array. The following facts apply to control arrays:
The set of controls that form a control array must be all of the same type (all textboxes, all labels, all option buttons, etc.)
You set up a control array by naming one or more controls of the same type the same name and set the Index property of each control in the array to a non-negative value (i.e., the controls in the control array are usually indexed from 0 to one less than the number of controls in the array).
The properties of the controls in the control array can vary: i.e., some members can be visible or not, they can be sized differently, they can have different fonts or colors, etc.
ControlName(Index)[.Property]
For example, to refer to the Text property of the first element of an array of textboxes called txtField, you would use:
txtField(0).Text
All the members of the control array share the same event procedure for example, if you have a control array of 10 textboxes call txtField, indexed 0 to 9, you will not have 10 different GotFocus events you will just have one that is shared amongst the 10 members. To differentiate which member of the control array is being acted upon, VB will automatically pass an Index parameter to the event procedure.