TabIndex Property
TOC
Collapse the table of content
Expand the table of content
The document is archived and information here might be outdated

Visual Basic Reference

Visual Studio 6.0

TabIndex Property

See Also    Example    Applies To

Returns or sets the tab order of most objects within their parent form.

Syntax

object.TabIndex [= index]

The TabIndex property syntax has these parts:

Part Description
object An object expression that evaluates to an object in the Applies To list.
index An integer from 0 to (n1), 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.

Remarks

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.

Show:
© 2016 Microsoft