Controls > Advanced Controls > List Box > List Box State Properties
List Box State Properties
Count
The Count property is read-only and returns the number of items in the list box. This property can be used to set up a loop to iterate through the control using methods such as GetText.
JScript
var longCount = ListBox.Count();

VBscript
longCount = ListBox.Count
Element
Description
longCount
The integer number of items in the list box.
CurSel
Sets or gets the index of the currently selected item in the list box. The index is zero based, so the first item in the list box has an index of 0. Returns constant LBERR if no item is selected.
If you set the CurSel property during the Start event, and the Run the Advanced Controls scripts on worksheet recalculate option is enabled, the user selection in the list box will reset during recalculation to the value specified in the script. To prevent this reset, ensure that the list box initialization occurs outside the Start event.
JScript
var longSelIndex = ListBox.CurSel();
ListBox.CurSel(longSelIndex);
VBscript
longSelIndex = ListBox.CurSel
ListBox.CurSel = longSelIndex
Element
Description
longSelIndex
The index of the selected item or item to select. The index is zero based.
LBERR and LBERRSPACE
Gets a test integer for errors on all list box properties and methods, except for AddString or InsertString methods, where you should 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.
JScript
var longLBERR = ListBox.LBERR();
var longLBERRSPACE = ListBox.LBERRSPACE();
VBscript
longLBERR = ListBox.LBERR
longLBERRSPACE = ListBox.LBERRSPACE
Element
Description
longLBERR
An integer value that indicates the setting of the LBERR or LBERRSPACE constant.
Was this helpful?