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
Python
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 Advanced Control script 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. To retain the current selection, you can save it to a local variable in your script and reassign it back further down your script.
JScript
var longSelIndex = ListBox.CurSel();
ListBox.CurSel(longSelIndex);
VBScript
longSelIndex = ListBox.CurSel
ListBox.CurSel = longSelIndex
Python
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
Gets a test integer for errors on all list box properties and methods. For example, the LBERR constant is returned as an error by the CurSel property when no item is selected.
JScript
var longLBERR = ListBox.LBERR();
VBScript
longLBERR = ListBox.LBERR
Python
longLBERR = ListBox.LBERR
Element
Description
longLBERR
An integer value that indicates the setting of the LBERR constant.
Was this helpful?