See Also Example
Applies To
File list box, list box
Description
Determines which item in a file list box or list box appears in the topmost position. The default is 0, or the first item in the list. Not available at design time.
Usage
[form.]{ filelistbox|listbox}.TopIndex[ = numericexpression ]
Remarks
Use this property to scroll through a file list box or list box without selecting an item.
If the Columns
If Columns is greater than 0, the item's column moves to the leftmost position without changing its position within the column.
Data Type
Integer
Help:
AddItem Method
Clear Method
List Property
ListCount Property
MultiSelect Property
NewIndex Property
RemoveItem Method
Selected Property
Programmer's Guide:
Chapter 3, "Creating and Using Controls"
The example fills a list box with names of screen fonts and then scrolls through the list box when you click the form. To try this example, paste the code into the Declarations section of a form that contains a list box. Then press F5 and click the form.
Sub Form_Load ()
Dim I ' Declare variable.
For I = 0 To Screen.FontCount -1 ' Fill list box with
List1.AddItem Screen.Fonts(I) ' screen font names.
Next I
End Sub
Sub Form_Click ()
Dim X ' Declare variable.
X = List1.TopIndex ' Get current index.
List1.TopIndex = List1.TopIndex + 5 ' Reset topmost item.
If List1.TopIndex = X Then List1.TopIndex = 0
End Sub