VB6 vs VB.NET controls - ListBox control

This section describes the differences between VB6 and .NET controls and the problems you can find in migrating VB6 applications with user-interface. The differences that are common to most controls are described in the Controls (general) section.

For a list of differences between VB6 and VB.NET language, see here.

Unless otherwise stated, VB Migration Partner fully supports all the Visual Basic 6 features mentioned in this page. It is worth noticing that names of properties and methods are preserved, which ensures that those even late-bound references work correctly after the migration to VB.NET. For more information, please read the manual and the knowledge base section.

ListBox control

AddItem method

The AddItem method isn’t supported and can be rendered using the Add or Insert methods of the Items collection, depending on whether the method receives an index argument.

Clear method

The Clear method isn’t supported under VB.NET; you can use the Items.Clear method instead.

Click event

The Click event in the VB.NET control doesn’t fire when a new element is selected via code or by using the keyboard. The actual .NET counterpart of this event is the SelectedIndexChanged event.

Columns property

The Columns property isn’t supported. You can approximate its effect by opportunely assigning the MultiColumn and ColumnWidth properties, which requires that you correctly calculate the width of each column.

VB Migration Partner fully supports this property.

DblClick event

The DblClick event maps to the DoubleClick event. However, you should also take into account that under VB6 no event fires if the mouse isn’t clicked on an element.

VB Migration Partner fully supports the DblClick event; as in VB6 no event fires if the mouse isn’t clicked on an element.

ItemCheck event

The ItemCheck event is supported but has a different syntax. Moreover, under VB6 this event fires when the checked state has been already assigned, whereas in VB.NET it fires before the assignment occurs. The code inside a VB6 event handler can reset the checked state of an element by simply assigning it, whereas code in a VB.NET event handler must assign the new state to the NewValue property of the ItemCheckEventArgs object passed as an argument to the event handler.

VB Migration Partner fully supports this event and automatically accounts for all the behavioral differences between VB6 and VB.NET.

ItemData property

The ItemData property isn’t supported by the VB.NET ListBox control. Code migrated by the Upgrade Wizard uses helper methods to render this property.

Interestingly, the items of a .NET ListBox control can be objects of any type, not just strings. If an object is used, the ListBox control displays whatever the object’s ToString method returns. If you need to associate data with an item, you can just create a class that contains two items, as in this example:

        Class ListItem
            Public ItemText As String   ' what is displayed
            Public ItemData As Object   ' associated data

            Public Overrides Function ToString() As String
                Return ItemText
            End Function
        End Class

VB Migration Partner fully supports this property; migrated code works correctly even if the control is accessed in late-bound mode.

List property

The List property isn’t supported; it can be rendered using the Items collection. Notice that the VB6 List property returns an empty string when the index is out of valid range, whereas you get an exception if you attempt to access a nonexisting element of the .NET Items collection. Along the same line, in VB6 you can create a new element by assigning the List property of the first available index:

        List1.List(List1.ListCount) = "new item"
This feature isn’t supported by the Items collection.

VB Migration Partner fully support this property, including all its quirks and undocumented behaviors.

ListCount property

The ListCount property isn’t supported under VB.NET; you can use the Items.Count property instead.

ListIndex property

The ListIndex property isn’t supported under VB.NET; you can use the SelectedIndex property instead.

MultiSelect property

The MultiSelect property isn’t supported and must be translated using the SelectionMode property.

NewIndex property

The NewIndex property isn’t supported; it broadly corresponds to the value returned by the Add method of the Items collection.

VB Migration Partner fully support this property, so that migrated code is guaranteed to work as intended.

RemoveItem method

The RemoveItem method isn’t supported and can be rendered using the RemoveAt method of the Items collection. There are other differences in behavior to take into account, though. For example, under VB6 the ListIndex property points to the element prior to the one being removed if the ListBox supports multiple selections, whereas in VB.NET the ListIndex property is always set to -1.

VB Migration Partner support this method and perfectly replicates all its quirks, thus no adjustments are necessary after the migration.

Scroll event

The Scroll event isn’t supported under .NET and it can’t easily simulated. For example, you can approximate it by hooking the SelectedIndexChanged event, but you wouldn’t trap the cases when the user scrolls the listbox contents without changing the current element. The only reliable way to get a notification when the ListBox control is scrolled is by means of Windows subclassing.

VB Migration Partner fully supports this event.

SelCount property

The SelCount readonly property isn’t supported; it can be rendered by means of the SelectedItems.Count property.

Selected property

The Selected property isn’t supported; it can be rendered by means of the GetSelected method for simple ListBox controls, or the GetItemChecked and SetItemChecked methods for ListBox controls with checkboxes.

Style property

The VB.NET ListBox control doesn’t support the Style property. ListBox controls with the Style property set to 1-vbListBoxCheckbox must be migrated to the CheckedListBox control instead of the ListBox control.

Both the Upgrade Wizard and VB Migration Partner migrate a ListBox with Style=1 to the most appropriate .NET control.

Follow Francesco Balena on VB6 migration’s group on


Read Microsoft Corp’s official case study of a VB6 conversion using VB Migration Partner.

Code Architects and its partners offers remote and onsite migration services.

More details

Subscribe to our free newsletter for useful VB6 migration tips and techniques.


To learn more about your VB6 applications, run VB6 Analyzer on your source code and send us the generated text file. You will receive a detailed report about your VB6 applications and how VB Migration Partner can help you to quickly and effectively migrate it to .NET.

Get free advice

A fully-working, time-limited Trial Edition of VB Migration Partner allows you to test it against your actual code

Get the Trial

The price of VB Migration Partner depends on the size of the VB6 application, the type of license, and other factors

Request a quote

Migrating a VB6 application in 10 easy steps

Comparing VB Migration Partner with Upgrade Wizard

Migration tools: Feature Comparison Table

All whitepapers