ListBox Methods

AddString, DeleteString, and InsertString

The AddString method adds a string item to the end of the ListBox list. If the Sort property is TRUE, string appears in the list in its sorted position. The DeleteString method deletes a string item from the ListBox list. The InsertString method inserts a string into the ListBox at a specified index.

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 string was added.

strItem

A string to be added to the ListBox.

intItem

A integer indicating the index of the item to remove.

FindString and FindStringExact

The FindString method finds the index of the first item in a ListBox 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. See SelectString to search and select an item.

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, entire ListBox is searched.

GetText

The GetText method get the text of an item at a specified index. Note that index is zero based.

strRet = ListBox.GetText(longIndex as Long)

Element

Description

stRet

The string at the specified index.

longIndex

The integer index at which to find the text.

Recalculate

The Recalculate method recalculates the control. Use within the framework of the Mathcad worksheet to force the scripted object to recalculate. This fires the Start, Exec, and Stop events. This method can be called from within events the control might listen for, including the SelChanged event. After the ListBox recalculates, any dependent expressions in the Mathcad worksheet will also update if AutoCalculate is on.

ListBox.Recalculate()

ResetContent

The ResetContent method clears the ListBox by removing all strings from the list.

ListBox.ResetContent()

SelectString

The SelectString method selects the string at a specified index of the ListBox.

longRet = ListBox.SelectString(longStartAfter as Long, strItem as String)

Element

Description

longRet

Returns the index of the selected string, or LBERR if no string is found.

strItem

The string to select.

longStartAfter

The location at which to start searching. -1 indicates to search the entire ListBox.