-
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
-
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)
-
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.