Control Arrays allow you to have a group of controls that can be accessed by the same name. Often, you might find that you need to specify a control to access at runtime... instead of having to create seperate code to do cmdAction1.Enabled... and cmdAction2.Enabled etc, you can use a Control array. Then, you could simply call cmdAction(i).Enabled where i is the number of the control in the array.
To create a control array, simply set the name of one control, and set its Index property to 0. Then, change the name of another control to the same name - this will then automatically be given an Index of 1. You can now access the control by calling objControlName(Index).
When controls are in an array, they also share the same event procedures... Instead of having cmdAction1_Click, cmdAction2_Click and so on, you can have cmdAction_Click(Index As Integer). This event is then triggered by VB each time on of the controls in the array is clicked. You can find out which control it is by checking the Index parameter.
Comments