ComboBox Question

dave_ie

Member
Joined
Mar 27, 2010
Messages
24
Programming Experience
Beginner
Im Writing a Program, and wondering how do i go about getting Text from a Comobox1 to show up in Listbox1? i also have lblCount.Text with 2 button increasing and decreasing quantities in lblCount.Text how do i get that showing on Listbox1 as well along side the Text of Comobox1
 
Do you mean something like:
VB.NET:
Listbox1.Items.Add(combobox1.Text & " " & lblCount.Text)
 
Thanks Man, I Writing a Program which give a User a list of Dvd when he clicks on one e.g Up and 3

Listbox1 shows
UP 3 @ $15.55 Ready To ship

for this to happen is it best to have them in Arrays ?
 
This is a Screen Shot, of the Program.

in the Comobox1 i have a List of Movies

when i click on 1, and click on add number quantities using Add Button.

which ever Movie i have click on it gives you the Name of the Movie with the Price of the move

Eg
Up 2 @ 15 Ready to Ship

VB.NET:
Imports System.IO
Public Class FirstForm
    Inherits System.Windows.Forms.Form
    Dim strComboBox1 As String
    Const intMax_DVD As Integer = 25
    Const intMax_email As Integer = 23
    Const intMax_price As Integer = 25
    Dim intprice(intMax_price) As Integer
    Dim strMail(intMax_email) As String
    Dim strCombobox(intMax_DVD) As String
    Dim dvdoreder As String
    Const sngTax_RATE As Single = 13.5
   

    Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click

        'Loads Log in Form

        Dim ThirdForm As New Form
        ThirdForm.Show()
    End Sub

    Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click

        'Loads Account Form

        Dim SecondForm As New Form
        SecondForm.Show()
    End Sub

    Private Sub txtCount_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblCount.TextChanged

    End Sub

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

    End Sub

    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click

        'Increasing Quantite of Dvd's 

        lblCount.Text = Val(lblCount.Text) + 1
    End Sub

    Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click

        'decreasing Quantite of Dvd's

        lblCount.Text = Val(lblCount.Text) - 1
    End Sub

    Private Sub btnRemove1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove1.Click

        'Removes Selected Items in Listbox1 
     
        ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

    End Sub

    Private Sub btnAdd1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd1.Click
        ListBox1.Items.Add(ComboBox1.Text & "  " & "     " & "   " & lblCount.Text)

        ' Dim decVat As Decimal
        ' Dim decTotal As Decimal

        ' Display the tax.
        'decVat = TaxCharges()
        ' decTotal = TaxCharges()
        'txtCost.Text = CInt("Total Cost inc. VAT & Delivery" & "c")

    End Sub

    'Private Sub Form1_load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    ' strCombobox(0) = "The Hang over"
    '     strCombobox(1) = "2012"
    '  strCombobox(2) = "Avatar"
    '  strCombobox(3) = "Up"
    '  strCombobox(4) = "The Hurt Locker"
    '  strCombobox(5) = "Harry Brown"
    '  strCombobox(6) = "Toy Story"
    '  strCombobox(7) = "Toy Story 2"
    '  strCombobox(8) = "Inglourious Basterds"
    '  strCombobox(9) = "A Serious man"
    '  strCombobox(10) = "Sherlock Homes 2009"
    ''  strCombobox(11) = "Transformers 2: Revenge Of The Fallen"
    '  strCombobox(12) = "Into The Wild"
    '  strCombobox(13) = " Gran Torino"
    ''strCombobox(14) = "Body of Lies"
    '  strCombobox(15) = "300"
    '  strCombobox(16) = "Lost: Complete Season 1 Box Set (5 Discs)"
    '  strCombobox(17) = "Lost: Complete Season 2 Box Set (5 Discs)"
    '  strCombobox(18) = "Lost: Complete Season 3 Box Set (5 Discs)"
    ''  strCombobox(19) = "Lost: Complete Season 4 Box Set (5 Discs)"
    '    strCombobox(20) = "Lost: Complete Season 5 Box Set (5 Discs)"
    '    strCombobox(21) = "House Season 1 Box Set "
    '  strCombobox(22) = "House Season 2 Box Set"
    '  strCombobox(23) = "House Season 3 Box Set "
    '  strCombobox(24) = "Prison Break Season 1 Box Set"
    '  strCombobox(25) = "Prison Break Season 2 Box Set"
    '  strCombobox(26) = "Prison Break Season 3 Box Set"

    '   intprice(0) = "14"
    '   intprice(1) = "15"
    '    intprice(2) = "22"
    ''   intprice(3) = "20"
    '   intprice(4) = "19"
    '    intprice(5) = "19"
    ' intprice(6) = "5"
    '  intprice(7) = "5"
    '  intprice(8) = "24"
    '  intprice(9) = "20"
    ''  intprice(10) = "18"
    'intprice(11) = "14"
    ''  intprice(12) = "15"
    '  intprice(13) = "16"
    '  intprice(14) = "13"
    '   intprice(15) = "18"
    '   intprice(16) = "50"
    '   intprice(17) = "50"
    '   intprice(18) = "53"
    ''   intprice(19) = "60"
    '   intprice(20) = "77"
    ''   intprice(21) = "43"
    '   intprice(22) = "44"
    '   intprice(23) = "44"
    '   intprice(24) = "30"
    '   intprice(25) = "35"
    '   intprice(26) = "45"

    'End Sub

    

    Function TaxCharges() As Decimal

        'Tax 

        Dim tax As Decimal
        Dim decShipping As Decimal = 1.2D

        tax = CDec(decShipping * sngTax_RATE)


        Return tax

    End Function

End Class
 
Last edited:
I have a Comobox1 with 26 items inside it, i added them in the Design Mode, not in the Code mode.

when a person clicks on any of the Items inside of Comobox1 that item should appear inside listbox1
VB.NET:
ListBox1.Items.Add(ComboBox1.Text & " " & " " & "" & lblCount.Text & "  " & " " & "Ready To Ship")
but how do i set up an array for the Combo box? to out put the Item the user clicks on and the price

My Public Class

VB.NET:
imports System.IO
Public Class FirstForm
    Inherits System.Windows.Forms.Form
    Const intMax_DVD As Integer = 25
    Const intMax_email As Integer = 23
    Const intMax_price As Integer = 25
    Const sngTax_RATE As Single = 13.5
    Dim intprice(intMax_price) As Integer
    Dim strCombobox1(intMax_DVD) As String


VB.NET:
 Private Sub Form1_load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Dim srtSentence As String

        'srtSentence = Word(strCombobox1)


        'strSentence = strSentence & " " & " " & " " & lblCount.Text & "  " & "Ready To Ship"

        'ListBox1.Items.Add(strCombobox1)
        strCombobox1(0) = "The Hang over"
        strCombobox1(1) = "2012"
        strCombobox1(2) = "Avatar"
        strCombobox1(3) = "Up"
        strCombobox1(4) = "The Hurt Locker"
        strCombobox1(5) = "Harry Brown"
        strCombobox1(6) = "Toy Story"
        strCombobox1(7) = "Toy Story 2"
        strCombobox1(8) = "Inglourious Basterds"
        strCombobox1(9) = "A Serious man"
        strCombobox1(10) = "Sherlock Homes 2009"
        strCombobox1(11) = "Transformers 2: Revenge Of The Fallen"
        strCombobox1(12) = "Into The Wild"
        strCombobox1(13) = " Gran Torino"
        strCombobox1(14) = "Body of Lies"
        strCombobox1(15) = "300"
        strCombobox1(16) = "Lost: Complete Season 1 Box Set (5 Discs)"
        strCombobox1(17) = "Lost: Complete Season 2 Box Set (5 Discs)"
        strCombobox1(18) = "Lost: Complete Season 3 Box Set (5 Discs)"
        strCombobox1(19) = "Lost: Complete Season 4 Box Set (5 Discs)"
        strCombobox1(20) = "Lost: Complete Season 5 Box Set (5 Discs)"
        strCombobox1(21) = "House Season 1 Box Set "
        strCombobox1(22) = "House Season 2 Box Set"
        strCombobox1(23) = "House Season 3 Box Set "
        strCombobox1(24) = "Prison Break Season 1 Box Set"
        strCombobox1(25) = "Prison Break Season 2 Box Set"
        strCombobox1(26) = "Prison Break Season 3 Box Set"

        intprice(0) = "14"
        intprice(1) = "15"
        intprice(2) = "22"
        intprice(3) = "20"
        intprice(4) = "19"
        intprice(5) = "19"
        intprice(6) = "5"
        intprice(7) = "5"
        intprice(8) = "24"
        intprice(9) = "20"
        intprice(10) = "18"
        intprice(11) = "14"
        intprice(12) = "15"
        intprice(13) = "16"
        intprice(14) = "13"
        intprice(15) = "18"
        intprice(16) = "50"
        intprice(17) = "50"
        intprice(18) = "53"
        intprice(19) = "60"
        intprice(20) = "77"
        intprice(21) = "43"
        intprice(22) = "44"
        intprice(23) = "44"
        intprice(24) = "30"
        intprice(25) = "35"
        intprice(26) = "45"
    End Sub
What i would like to do if a Person clicks on Avatar inside the Como box and clicks add.
something like this should Appear inside list box how can i do this ?
So it should look like
Avatar 1 @ $22 Read to Ship
 
Last edited:
Back
Top