ComboBox add Items

January 20, 2011 at 09:07:34
Specs: Windows XP

I am encountering a problem in Excel VBA in adding items to the combo box.

I used this code:

Private Sub cbox_DropButtonClick()

cbox.AddItem "DO at Distance x (mg/L)", 0
cbox.AddItem "Critical Time (d)", 1
cbox.AddItem "DO at Critical Time (mg/L)", 2
cbox.AddItem "Distance at Critical Time (km)", 3

End Sub

However, everytime i click the arrow of the combo box, the items double.

I tried putting cbox.Clear at the beginning and the end of the code but it led to other problems.

Please Help!

See More: ComboBox add Items

Report •

January 20, 2011 at 09:23:22
It will, you have put yourself in an illegal loop.

cbox_DropButtonClick() event is triggered when the drop down box is clicked. The combo box should be populated somewhere else, possibly in the form load event. not in an event that is triggered by the combo box itself. By then the combo should have already been populated.

As this is a programming problem I have moved it to programming.


Report •
Related Solutions

Ask Question