Jump to content

Listbox in vb


 Share

Recommended Posts

i have some question of a listbox. how can i declare a variable in the list box e.g

Dim As software ("Norton")

Select Case cbProduct.SelectedIndex

Case 0

lbItems.Items.Clear()

lbItems.Items.AddRange(Software)

Exit Select

End Select

End Sub

im so sick to research i cannot figure it out.

Edited by solid2005
Link to comment
Share on other sites

What exactly are you trying to accomplish here? Your Dim statement makes no sense. Do want to assign a value from a combo box to a listbox? If so, try this.

if MyComboBox.BoundText > "" Then
    MyListBox.AddItem(MyComboBox.Text)
    MyComboBox.BountText = ""
    DoEvents   ' Allow MyComboBox to refresh.
EndIf

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Link to comment
Share on other sites

Dim Software() As String = {"Norton Internet Security 2009", "Windows Xp Professional Sp2", "WIndows Xp Home Edition Sp2", "Windows Vista Ultimate Edition", "Windows Vista Business Edition", "Windows Vista Starter Edition", "Windows Vista Basic Edition", "Windows Vista Home Edition", "Adobe Photoshop CS4", "Visual Studio Professional 2008 Edition", "Visual Studio Enterprises 2008 Edition", "Microsoft Office Professional 2003 Sp2", "Microsoft Office Professional 2007", "Norton Gaming Edition 2009", "AVG Professional 2009", "AVG Internet Security 2009", "Microsoft SQL 2008", "Microsoft SQL 2005", "Microsoft SQL 2000", "Avira Internet Security 2009"}
    Dim Vegetable() As String = {"Artichoke", "Asparagus", "Aubergene", "Beans", "Beet", "Broccoli", "Brussels sprouts", "Cabbage", "Carrot", "Cauliflower", "Celeriac", "Celery", "Chard", "Chicory", "Collards", "Corn", "Cress", "Cucumbers", "Gourds", "Mushrooms"}

    Private Sub frmOrderCart_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cbProduct.SelectedIndex = 0
    End Sub

    Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
        lbItemRecieve.Items.Clear()
        cbProduct.SelectedIndex = 0
    End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Close()
    End Sub

    Private Sub lbItems_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbItems.DoubleClick
        lbItemRecieve.Items.Add(lbItems.SelectedItem)
    End Sub

    Private Sub cbProduct_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbProduct.SelectedIndexChanged
        Select Case cbProduct.SelectedIndex
            Case 0
                lbItems.Items.Clear()
                lbItems.Items.AddRange(Software)
                Exit Select
            Case 1
                lbItems.Items.Clear()
                lbItems.Items.AddRange(Vegetable)
                Exit Select
        End Select
    End Sub

    Private Sub lbItemRecieve_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbItemRecieve.DoubleClick
        lbItemRecieve.Items.Remove(lbItemRecieve.SelectedItem)
    End Sub

I get error in you code im using vb.net in studio 2008

Edited by solid2005
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...