multiselect remove

K

King

Hi,

I am using mulitselect listbox. when user clicks remove button, i want
to remove all the selected items from multiselect listbox in a single
shot. i used folloing code, but it is throwing an error "Could not get
selected property, invalid arguments",

For i = 0 To SelectListBox.ListCount - 1
If SelectListBox.Selected(i) = True Then
SelectListBox.RemoveItem (i)
End If
Next

any help?

thanks,

King.
 
T

Tom Ogilvy

Loop from highest to lowest.

For i = SelectListBox.ListCount - 1 to 0 Step -1
If SelectListBox.Selected(i) = True Then
SelectListBox.RemoveItem (i)
End If
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top