ListBox Control

Adding Items

To add an item to a listbox during design time, select the Items property box, and press the drop down button. Enter the items you want to be displayed. Press Ctrl+Return to insert another item. Press Return to apply the changes, Esc to cancel

To add an item to a listbox during runtime, you can use the following syntax:

List1.AddItem Item, Index

where Item is a string containing the text to be displayed for that item. Index is an optional value to identify that item. You can only use a valid value. For example:

List1.AddItem "David", 4

is only valid if the list already has 4 items (remember the index starts from 0) If omitted, a default value is added. (0 is the first item on the list, 1 the second and so on). The following code adds three items to a combo box: David, Paul and Sarah.

List1.AddItem "David"
List1.AddItem "Paul"
List1.AddItem "Sarah"

You might also like...


About the author

James Crowley

James Crowley United Kingdom

James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audien...

Interested in writing for us? Find out more.


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.”