List Box State Properties

Count

The Count property is read-only and returns the number of items in the list box. This important property can be used to set up a loop to iterate through the control using methods such as GetText.

longCount = ListBox.Count

Element

Description

longCount

The integer number of items in the list box.

CurSel

The CurSel property sets or gets the index of the currently selected item in the list box. Index is zero-based, so the first item in the list box has an index of 0. Returns constant LBERR if no item selected.

longSelIndex = ListBox.CurSel
ListBox.CurSel = longSelIndex

Element

Description

longSelIndex

The index of the selected item or item to select. Zero based.

LBERR and LBERRSPACE

The LBERR property gets a test integer for errors on all list box properties and methods, except AddString or InsertString methods, in which case, use the LBERRSPACE property to test for insufficient memory. For example, the LBERR constant is returned as an error by the CurSel property when no item is selected.

longLBERR = ListBox.LBERR         longLBERRSPACE = ListBox.LBERRSPACE

Element

Description

longLBERR

An integer value that indicates the setting of the LBERR or LBERRSPACE constant.

RightToLeftReadingOrder

The RightToLeftReadingOrder property sets or gets a value that determines whether the text is read right-to-left. Often used for Kanji.

bMode = ListBox.RightToLeftReadingOrder
ListBox.RightToLeftReadingOrder = bMode

Element

Description

bMode

True indicates that the text ordering is right-to-left; false indicates left-to-right.