How to Access & Clear a ListBox Selection

Written by jaime avelar
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Access & Clear a ListBox Selection
Remove ListBox item selected using Visual Basic. (Hemera Technologies/ Images)

Programmers often display a list of items through a "ListBox" control from which the user can choose. Depending on your application, you may want to give the user the flexibility to remove items they don't use. In Visual Basic, you can use the "Items" property to obtain a reference to the list of items currently stored in the ListBox control. With that reference, you can add or remove items. Use the "Selected Item" to access the current selection and clear it.

Skill level:
Moderately Easy

Other People Are Reading

Things you need

  • Microsoft Visual Basic Express

Show MoreHide


  1. 1

    Launch Microsoft Visual Basic Express, click "New Project" on the left pane of your computer screen, and double-click "Windows Forms Application" to create a new project.

  2. 2

    Double-click "ListBox" from the "Toolbox" pane to add a new ListBox to the form. Double-click "Button" to create a new button on your form.

  3. 3

    Double-click the form to create a new "Load" event procedure, and add the following code to add five new items to the ListBox:

    Me.ListBox1.Items.Add("first item")

        Me.ListBox1.Items.Add("second item")
        Me.ListBox1.Items.Add("third item")
        Me.ListBox1.Items.Add("fourth item")
        Me.ListBox1.Items.Add("fifth item")
  4. 4

    Double-click the button to create a new click event procedure, and add the following code to access and clear the current item selected:


  5. 5

    Press "F5" to run the program and click any item on the ListBox control. Click "Button1" to clear the item.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.