ItemData property cannot be upgraded

In Visual Basic 6.0 the ItemData property for a ListBox or ComboBox control could be set at design time in the Properties window to associate an Integer with a ListBox or ComboBox item.

In Visual Basic 2008 the ItemData property no longer exists. The Visual Basic Compatibility library (Microsoft.VisualBasic.Compatibility) contains a SetItemData function that can be used to associate an Integer with an item; the GetItemData function can be used to retrieve the item.

When a Visual Basic 6.0 project is upgraded, any values in the ItemData property are discarded.

What to do next

  1. In your Visual Basic 6.0 project, check the List and ItemData properties for the ListBox or ComboBox controls in the Properties window to see the values that were entered at design time.

  2. In the upgraded project, add code to the Form_Load procedure to assign the ItemData property at run time using the SetItemData function from the Visual Basic Compatibility library.

    ' Visual Basic 2008
    ' In the original project, values of 123, 456, and 789 were set at 
    ' design time for the first three items in a ListBox.
    VB6.SetItemData(List1, 0, 123)
    VB6.SetItemData(List1, 1, 456)
    VB6.SetItemData(List1, 2, 789)

Community Additions