By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,495 Members | 1,158 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,495 IT Pros & Developers. It's quick & easy.

Listbox Do Loop problem...

P: 22
Hi, I have a list box (called genredelete) and i'm trying to write a procedure to delete all the selected items in the list box. The code i have written to do this is as follows:

Expand|Select|Wrap|Line Numbers
  1.         Dim indexnum As Integer
  2.  
  3.         indexnum = 0
  4.  
  5.         Do Until indexnum = GenreDelete.ListCount
  6.  
  7.             If GenreDelete.Selected(indexnum) = True Then
  8.                 GenreDelete.RemoveItem (indexnum)
  9.             Else
  10.                 indexnum = indexnum + 1
  11.             End If
  12.  
  13.         Loop
  14.  
The problem is when run only the first selected item is removed and then the loop appears to stop. I have also tried reversing the do loop (so it removes items from the bottom up) and using a for next. However the same problem occurs there as well. Any pointers?
Jan 29 '08 #1
Share this Question
Share on Google+
1 Reply


100+
P: 365
try putting "me." inforont of your listbox name

as in

Me.GenreDelete............

(or [forms]![frmFormName].[GenreDelete])

that would be my first thought

Dan
Jan 29 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.