ItemData

This property returns and sets a specific number for each item in a ComboBox control, ListBox control, or CommandBarComboBox object.

Syntax

object.ItemData(index) [= number]

Parameters

object
Object expression that evaluates to a ComboBox, ListBox, or CommandBarComboBox.
index
Number of a specific item in the ComboBox, ListBox, or CommandBarComboBox.
number
Number to be associated with the specified item.

Remarks

The ItemData property is an array of Long integer values with the same number of items as a control's List property. You can use the numbers associated with each item to identify the items. For example, you can use an employee's identification number to identify each employee name in a ListBox control. When you fill the ListBox, also fill the corresponding elements in the ItemData array with the employee numbers.

The ItemData property often is used as an index for an array of data structures associated with items in a ListBox control.

When you insert an item into a list with the AddItem method, an item is automatically inserted in the ItemData array as well. However, the value is not reinitialized to 0; it retains the value that was in that position before you added the item to the list. When you use the ItemData property, be sure to set its value when adding new items to a list.