ListIndex

Returns or sets the index of the currently selected item in the control. Not available at design time.

Syntax

object.ListIndex [= index]

The parts of the ListIndex property syntax are described in the following table.

Part Description
object An object expression that evaluates to an object.
index A numeric expression specifying the index of the current item, as described in Settings.

Settings

The settings for index are described in the following table.

Setting Description
–1 (Default for ComboBox). Indicates no item is currently selected. For a ComboBox control, indicates the user has entered new text into the text box portion.
n (Default for ListBox controls). A number indicating the index of the currently selected item.

Remarks

The expression List(List1.ListIndex) returns the string for the currently selected item.

The first item in the list is ListIndex = 0, and ListCount is always one more than the largest ListIndex value.

For a control in which users can make multiple selections, this property's behavior depends on the number of items selected. If only one item is selected, ListIndex returns the index of that item. In a multiple selection, ListIndex returns the index of the item contained within the focus rectangle, whether or not that item is actually selected.