Controls > Advanced Controls > List Box > List Box Methods
List Box Methods
AddString, DeleteString, and InsertString
The AddString method adds a string item to the end of the list box. If the Sort property is TRUE, a string appears in the list in its sorted position. The DeleteString method deletes a string item from the list box list. The InsertString method inserts a string into the list box at a specified index.
JScript
longRet = ListBox.AddString(strItem as String);
longRet = ListBox.DeleteString(intItem as Long);
longRet = ListBox.InsertString(longIndex as Long, strItem as String);
VBscript
longRet = ListBox.AddString(strItem as String)
longRet = ListBox.DeleteString(intItem as Long)
longRet = ListBox.InsertString(longIndex as Long, strItem as String)
Element
Description
longRet
Returns the index at which the string was added.
strItem
A string to be added to the list box.
intItem
An integer indicating the index of the item to remove.
FindString and FindStringExact
The FindString method finds the index of the first item in a list box, which contains the string argument, as well as other characters. The FindStringExact method searches for the first identical match to the whole string with no additional characters. Search is case independent for both methods.
JScript
longRet = ListBox.FindString(longStartAfter as Long, strItem as String);
longRet = ListBox.FindStringExact(longStartAfter as Long, strItem as String);
VBscript
longRet = ListBox.FindString(longStartAfter as Long, strItem as String)
longRet = ListBox.FindStringExact(longStartAfter as Long, strItem as String)
Element
Description
longRet
Returns the index at which the string was found or LBERR if not found.
strItem
The string to search for.
longStartAfter
An integer indicating the index at which to begin search. If set to -1, the entire list box is searched.
GetText
The GetText method gets the text of an item at a specified index. Note that the index is zero based. This method is recommended to use with the CurSel property to get the current text. If the longIndex value is not valid or missing, the value of LBERR is set to –1 and the function returns an empty string.
JScript
var longIndex = ListBox.CurSel();
var strRet = ListBox.GetText(longIndex);
VBscript
longIndex = ListBox.CurSel
strRet = ListBox.GetText(longIndex)
Element
Description
strRet
The string at the specified index.
longIndex
The integer index at which to find the text.
ResetContent
The ResetContent method clears the list box by removing all strings from the list.
JScript
ListBox.ResetContent {};
VBscript
ListBox.ResetContent()
Was this helpful?