ListIndex

This property returns and sets the index of the currently selected item in a ListBox or ComboBox control.

Syntax

object.ListIndex [= index]

Parameters

object
Object expression that evaluates to a ListBox or ComboBox control.
index
Numeric expression that specifies the index of the current item. Following are the settings for index:
–1
(Default for ComboBox). Indicates no item is currently selected. For a ComboBox control, indicates a user has entered new text into the text box portion.
n
(Default for ListBox controls). Number that indicates the index of the currently selected item.

Remarks

The ListIndex property is unavailable at design time.

The following expression returns the string for the currently selected item.

List(List1.ListIndex)

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.