I have a listbox populated with the full path of several items from a directory. I'm attempting to delete only the selected(checked) items using the following code.
It works on 1 or 2 items if they are not consecutive in the list.(next to one another), but If I select all the items or 2 consecutive items, I get a File Not Found error and when I debug, the listbox text value is the item it most recently deleted. Any help would be greatly appreciated.
Thanks,
Harold
***You can't change your past, but you can change your future***
Code:
Dim i As Long
If List1.ListIndex = -1 Then Exit Sub
For i = List1.ListCount - 1 To 0 Step -1
If List1.Selected(i) = True Then
Kill List1.Text
List1.RemoveItem i
End If
Next i
It works on 1 or 2 items if they are not consecutive in the list.(next to one another), but If I select all the items or 2 consecutive items, I get a File Not Found error and when I debug, the listbox text value is the item it most recently deleted. Any help would be greatly appreciated.
Thanks,
Harold
***You can't change your past, but you can change your future***