Visual Basic Reference
ItemData Property
Returns or sets a specific number for each item in a ComboBox or ListBox control.
Syntax
object.ItemData(index) [= number]
The ItemData property syntax has these parts:
Part | Description |
Object | An object expression that evaluates to an object in the Applies To list. |
Index | The number of a specific item in the object. |
Number | The 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 is often used as an index for an array of data structures associated with items in a ListBox control.
Note 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 isn't reinitialized to zero; 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.