ListIndex Property

See Also3OLKHX5                 Example65ZL0YQ>Low

Applies To

Combo box1YZXFF6, directory list boxO9U5A0, drive list box5WJO0PW, file list box1M6S8UX, list boxG11UCK.


Determines the index1L6K9K3 of the currently selected item in the control.  Not available at design time.



[form.]control.ListIndex[ = index ]


The ListIndex property settings are:

Setting             Description


-1                     (Default for combo box, directory list box, and drive list box) Indicates no item is currently selected.  For a combo box, indicates the user has entered new text into the text box portion of the combo box.  For a directory list box, indicates the index of the current path.  For a drive list box, indicates the index of the current drive when the control is created at run time.

n                      (Default for file list box and list box) A number indicating the index of the currently selected item.



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.

Data Type


See Also:


AddItem Method2BIX3OB

Drive PropertyYLV8AS

List PropertyBKCX6E

ListCount Property4E91QN

Path PropertyBKGP79

RemoveItem MethodM867OS


Programmer's Guide:

Chapter 3, "Creating and Using Controls"

ListIndex Property Example

The example displays the names of three players in a list box and the corresponding salary of the selected player in a label.  To try this example, paste the code into the Declarations section of a form that contains a combo box and a label.  Then press F5 and choose a name from the combo box.

' General declarations
Dim Player(0 To 2)           ' Dimension two arrays.
Dim Salary(0 To 2)
Sub Form_Load ()
  Dim I                      ' Declare variable.
  AutoSize = True
  Player(0) = "Miggey McMoo" ' Enter data into arrays.
  Player(1) = "Alf Hinshaw"
  Player(2) = "Woofer Dean"
  Salary(0) = "$234,500"
  Salary(1) = "$158,900"
  Salary(2) = "$1,030,500"
  For I = 0 To 2             ' Add names to list.
    Combo1.AddItem Player(I)
  Next I
  Combo1.ListIndex = 0       ' Display first item in list.
End Sub
Sub Combo1_Click ()
  ' Display corresponding salary for name.
  Label1.Caption = Salary(Combo1.ListIndex)
End Sub