Control Array Changes in Visual Basic .NET
In Visual Basic 6.0, control arrays could be used to specify a group of controls that shared a set of events. The controls had to be of the same type, and they had to have the same name.
In Visual Basic .NET, control arrays are no longer supported. Changes to the event model make control arrays unnecessary. Just as control arrays in Visual Basic 6.0 could share events, the event model in Visual Basic .NET allows any event handler to handle events from multiple controls. In effect, this allows you to create groups of controls of disparate types that share the same events.
For example, you might add two Button controls (Button1 and Button2) and a CheckBox control (CheckBox1) to a form, then create an event handler to handle the Click event for all three controls:
Private Sub MixedControls_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, CheckBox1.Click
Another feature of Visual Basic 6.0 control arrays was the ability to reference a control by its Index property. Although Visual Basic .NET controls do not have an Index property, you can duplicate the functionality using another common property such as the TabIndex or Tag property.
For example, you might set the TabIndex property for a group of controls using the new visual tab ordering capabilities of Windows Forms, and then use the TabIndex in a Select Case statement:
Private Sub MixedControls_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, CheckBox1.Click Select Case sender.TabIndex Case 0 MsgBox("Button 1") Case 1 MsgBox("Button 2") Case 2 MsgBox("CheckBox 1") End Select End Sub