TabIndex Property (ActiveX Controls)
Returns or sets the tab order of most objects within their parent form.
object.TabIndex [= index]
The TabIndex property syntax has these parts:
|object||An object expression that evaluates to an object in the Applies To list.|
|index||An integer from 0 to (n–1), where n is the number of controls on the form that have a TabIndex property. Assigning a TabIndex value of less than 0 generates an error.|
By default, Visual Basic assigns a tab order to controls as you draw them on a form, with the exception of the Menu, Timer, Data, Image, Line and Shape controls, which are not included in the tab order. At run time, invisible or disabled controls and controls that can't receive the focus (Frame and Label controls) remain in the tab order but are skipped during tabbing.
Each new control is placed last in the tab order. If you change the value of a control's TabIndex property to adjust the default tab order, Visual Basic automatically renumbers the TabIndex of other controls to reflect insertions and deletions. You can make changes at design time using the Properties window or at run time in code.
The TabIndex property isn't affected by the ZOrder method.
Note A control's tab order doesn't affect its associated access key. If you press the access key for a Frame or Label control, the focus moves to the next control in the tab order that can receive the focus.
When loading forms saved as ASCII text, controls with a TabIndex property that aren't listed in the form description are automatically assigned a TabIndex value. In subsequently loaded controls, if existing TabIndex values conflict with earlier assigned values, the controls are automatically assigned new values.
When you delete one or more controls, you can use the Undo command to restore the controls and all their properties except for the TabIndex property, which can't be restored. TabIndex is reset to the end of the tab order when you use Undo.
This example reverses the tab order of a group of buttons by changing the TabIndex property of a command button array. To try this example, paste the code into the Declarations section of a form that contains four CommandButton controls. Set the Name property to CommandX for each button to create the control array, and then press F5 and click the form to reverse the tab order of the buttons.
Private Sub Form_Click () Dim I, X ' Declare variables. ' Reverse tab order by setting start value of X. If Command1(0).TabIndex = 0 Then X = 4 Else X = 1 For I = 0 To 3 Command1(I).Caption = X ' Set caption. Command1(I).TabIndex = X - 1 ' Set tab order. If Command1(0).TabIndex = 3 Then X = X - 1 ' Decrement X. Else X = X + 1 ' Increment X. End If Next I End Sub
Applies To: MSChart Control