[RESOLVED]ComboBox - stupid problem
Hi All
Just stupid problem or I have eclipse mind.
I’ve an form 1 Combo and 1 CommandButton, I practise writing loop For...Next
What am I doing wrong? I Want clear all items in ComboBox. I make such code.
VB Code:
Private Sub Command1_Click()
For i = 0 To Combo1.List(i)
Combo1.RemoveItem.List
Next
End Sub
And don't work, why?
thanks for every help
Re: ComboBox - stupid problem
Just do:
or if you wanted to do it your way:
VB Code:
For N = 0 To Combo1.ListCount - 1
Combo1.RemoveItem 0
Next N
Re: ComboBox - stupid problem
really,........ how I could does not think about this
Thanks very, very much
Re: ComboBox - stupid problem
try this:
VB Code:
Private Sub Command1_Click()
Dim i%
For i = (Combo1.ListCount) To 1 Step -1
Combo1.RemoveItem (i - 1)
Next i
End Sub
backward loop because, when you delete 1 item, the list gets organised automatically. i.e. if you delete 3rd element, then the 4th one becomes 3rd, 5th becomes 4th and so on.
Harsh Gupta
Re: ComboBox - stupid problem
Thanks Harsh Gupta, your code is fine, I will test this