Top

Description

Obtains the index number of the first visible item in a ListBox control. Top lets you to find out how the user has scrolled the list.

Applies to

ListBox and PictureListBox controls

Syntax

listboxname.Top ( )

Argument

Description

listboxname

The name of the ListBox or PictureListBox in which you want the index of the first visible item in the list

Returns

Integer. Returns the index of the first visible item in listboxname. Top returns -1 if an error occurs. If listboxname is null, Top returns null.

Usage

The index of a list item is its position in the full list of items, regardless of how many are currently visible in the control.

Examples

Example 1

If item 15 has been scrolled to the top of the list in lb_Contacts, then this example sets Num to 15:

integer Num

Num = lb_Contacts.Top()

Example 2

If the user has not scrolled the list in lb_Contacts, then Num is set to 1:

integer Num

Num = lb_Contacts.Top()

Example 3

If the item at the top of the list in lb_Contacts is not the currently selected item, the following statements scroll the currently selected item to the top:

integer Num

Num = lb_Contacts.SelectedIndex()

IF lb_Contacts.Top() <> Num THEN &

      lb_contacts.SetTop(Num)

See also