AddItem Method

Applies To

DrawingObjects Collection, DropDown Object, DropDowns Collection, ListBox Object, ListBoxes Collection.

Description

Adds an item to a list box or drop-down list box.

Syntax

object.AddItem(text, index)

object

Required. The object to which this method applies.

text

Required. Specifies the text string to add.

index

Optional. Specifies the position at which to add the new entry. If the list has fewer entries than the specified index, blank items are added from the end of the list to the specified position. If this argument is omitted, the item is appended to the existing list.

Remarks

Using this method clears any range specified by the ListFillRange property.

See Also

List Property, RemoveItem Method.

Example

This example replaces the existing contents of list box one on Dialog1 with the letters A through M.


DialogSheets("Dialog1").ListBoxes(1).RemoveAllItems
For i = 65 To 77
    DialogSheets("Dialog1").ListBoxes(1).AddItem Text:=Chr(i)
Next i