eHow launches Android app: Get the best of eHow on the go.

How To

How to Add Items to a Listbox in VB.net

Member
By Mike
User-Submitted Article
(5 Ratings)
VB.net
VB.net

A listbox is very common control that you see in many applications. It gives the user a great view of a list of items. Here is how you add items to a listbox in VB.net.

Difficulty: Easy
Instructions

Things You'll Need:

  • VB.net
  1. Step 1

    Open in VB.net.

  2. Step 2
    New Project
     
    New Project

    Create a new proejct.

  3. Step 3
    Listbox
     
    Listbox

    Add a listbox to the form.

  4. Step 4
    Button
     
    Button

    Add a button to the form.

  5. Step 5
    Code Window
     
    Code Window

    Double click the button to bring up the button's click event code window.

  6. Step 6
    Code
     
    Code

    In the code window we create a FOR-NEXT loop to add a list of numbers. Then to add items to the listbox we use the "ListBox1.Items.Add i". See the picture for the exact code.

  7. Step 7

    Press the "F5" key on your keyboard to run the program.

  8. Step 8
    Final Results
     
    Final Results

    Click the button on the form and you will see the numbers added to the listbox.

Resources

Comments  

mpodlesny said

Flag This Comment

on 11/5/2008 this example is just that an example.

josinathan said

Flag This Comment

on 11/4/2008 i have a problem by using this code, that is if i close the application and reopen it the added item does not present in that purticulur Listbox what i have to do

luv2blog said

Flag This Comment

on 10/12/2008 Thanks for the info.

argyle said

Flag This Comment

on 10/7/2008 I get this question all the time from newbies. I hope they all find their answer here next time! Thanks for the article.

Subscribe

Post a Comment

Post a Comment

Related Ads

  • Have you done this? Click here to let us know.
I Did This
Get Free Computers Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy.   en-US Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.

eHow Computers
eHow_eHow Technology and Electronics