Results 1 to 3 of 3

Thread: Adding the content of cboBox

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2000
    Posts
    118
    How do I add the items in a combo box. I tried this code, but if I put in 100,100,200, it adds 100 three times.Private Sub Command1_Click()

    Dim x As Integer
    Dim i As Integer
    Dim sum As Integer
    i = 0
    Do Until i = combo.ListCount
    sum = sum + combo.List(x)
    i = i + 1
    Loop

    txtSum = sum + Val(txtOpen.Text)
    End Sub

  2. #2
    New Member
    Join Date
    Sep 1999
    Location
    Spain
    Posts
    12

    Thumbs up

    Hey kokopeli, you made a code mistake. You are using x as index to get the values from the combo.list array, but you are not setting any value to x, so it always is 0 and combo.List(x) always returns to you the first combo item:100. Your code might seem to this:

    Dim x As Integer
    Dim i As Integer
    Dim sum As Integer

    i = 0
    Do Until i = combo.ListCount
    'sum = sum + combo.List(x) Error: x is always 0
    sum = sum + combo.List(i)
    i = i + 1
    Loop

    txtSum = sum + Val(txtOpen.Text)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2000
    Posts
    118

    Thanks

    I figured that out right before you posted. I thought I had tried that but I must have done something else. Thank you much for the help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width