Export (0) Print
Expand All
Expand Minimize

NewIndex property cannot be upgraded

Visual Studio .NET 2003

In Visual Basic 6.0 the NewIndex property was used to retrieve the index of the item most recently added to a ListBox or ComboBox control. During upgrade, the value of NewIndex cannot be determined in some cases. The return value from the Items.Add method can be used instead of NewIndex.

What to do next

  • Review the usage of the NewIndex property and modify your code as in the following example.
    ' Visual Basic 6.0
    List1.AddItem "Hello"
    List1.ListIndex = List1.NewIndex
    ' After upgrade to Visual Basic .NET
    ' UPGRADE_ISSUE: ListBox property Form1.List1.NewIndex was not upgraded.
    List1.SelectedIndex = List1.NewIndex    ' Causes a compilation error.

    The Visual Basic .NET code should then be modified as follows:

    Dim x As Integer
    x = List1.Items.Add("Hello")
    List1.SelectedIndex = x

See Also

ComboBox Control Changes in Visual Basic .NET | ListBox Control Changes in Visual Basic .NET

© 2015 Microsoft