Removing items from a combo box?

  • Thread starter Thread starter Ian
  • Start date Start date
I

Ian

Using Word 97.

A very basic VBA question.

I am using AddItem to place items from a string array into a combo box
list:

~~~~~~~~~~~~~~
mystring(1) = "qwerty"
mystring(2) = "asdfgh"
.....
mystring(10) = "mnbvcx"

With MyForm
For n = 1 to 10
.myComboBox.AddItem mystring(n)
Next

~~~~~~~~~~~~~~~

This works fine. When I click on the scroll bar, the list of items
appears.

However, at a later time, I want to re-load the box with a different
list. But if I use similar code to the above, the new items are *added*
to the original list. I just want to *replace* the original list.

The question then is: How do I remove the original items before adding
new ones?
 
Hi, Ian,

Use the command myComboBox.Clear to empty the list, then add the new
items.
 
Now why didn't I think of that. Thanks Jay.

(Actually, the reason I didn't think of that is because the book I am
using for reference -- "Mastering VBA6" by Guy Hart-Davis -- does not
seem to mention it anywhere).
 
Back
Top