How to Add Items to ComboBox in VB

Written by jaime avelar
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Add Items to ComboBox in VB
Use VB.NET to add items to a combo box control. (0101000100111 image by chrisharvey from Fotolia.com)

Adding items to a combo box control in Microsoft Visual Basic .NET (VB.NET) can cost you time if you don't know how to accomplish the task. A combo box control is a combination of a text box and a list box that provides options for the user to select. A user can either enter data in the text box or choose an item from the list. VB.NET is an object-oriented programming language used to create desktop, phone and web applications quickly.

Skill level:
Easy

Other People Are Reading

Things you need

  • Microsoft Visual Basic Express

Show MoreHide

Instructions

  1. 1

    Start Microsoft Visual Basic Express, click "New Project..." on the left pane of your screen, then select "Windows Forms Application." Click "OK."

  2. 2

    Double-click "Button" on the "Toolbox" pane to add a new button control. Double-click "ComboBox" to add a combo box control.

  3. 3

    Double-click "Button1" to open the "Form1.vb" module. Press "Ctrl" + "A," then press "Delete" to remove all existing code.

  4. 4

    Copy and paste the following code to your "Form1.vb" module:

    Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
    
    
        ComboBox1.Items.Add("Item")
    
        ComboBox1.Items.Add("Item")
    
        ComboBox1.Items.Add("Item")
    
        ComboBox1.Items.Add("Item")
    
        ComboBox1.Items.Add("Item")
    
        ComboBox1.Text = ComboBox1.Items(0).ToString
    
    
    
    End Sub
    

    End Class

  5. 5

    Press "F5" to load items to the combo box control.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

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