InsertItem Method (AListBox)

Insert an item to the object control at a specified position.

Syntax

[ lInsertItem = ] Object.InsertItem ( lIndex, sItem )

The InsertItem method syntax has the following parts:

 

Name

Type

Description

Object

AListBox

AListBox control

lIndex

Val Long

A number specifying the zero-based location of the item to be inserted in the array of items in the object.

sItem

Val BString

The text string being inserted.

lInsertItem

Long

Insert an item to the control at a position specified by lIndex.

Comments

If lIndex is -1, then the item is appended to the end of the list. The return value is the zero-based index of the string in the list box. If an error occurs, the return value is -1, for example, there is insufficient space to store the new string.

Example

The following example will insert the text string "grapes" by value to the AListBox before the current 6th item.:

lb1.InsertItem(5)="grapes"

Applies to

AListBox

See Also

AddItem, FindItem, RemoveItem, Sorted