Question: Deleting Multiple Items in ListBox?? 
Author Message
 Question: Deleting Multiple Items in ListBox??

Hi everyone,

This is just another "easy" problem that I'm stuck with.  Basically, I
have two list box, LEFT & RIGHT.
The one on the left contains several items and I have one command button
to move multiple items that I selected by holding SHIFT or CTRL key
while clicking the left mouse button.  The problem is, I also want to
delete all the items that are moved from left to right.  As it stands
right now, I'm only copying the selected items on the left to the
right.  So my question is how can I delete all the selected items after
I moved them to the right list box?

I have tried to do:

       If lstLeft.Selected(I) Then
            lstRight.AddItem lstLeft.List(I)
            lstLeft.RemoveItem (I)
       End If

But it only deleted every other item that I selected before the program
finally crashed.  Your help would be greatly appreciated.  Thanks in


PS: This is the code I have for the command button (below):

Private Sub cmdMoveMultiple_Click()
    Dim intNumItem, I As Integer
    intNumItem = lstLeft.ListCount

    For I = 0 To intNumItem - 1
       If lstLeft.Selected(I) Then
            lstRight.AddItem lstLeft.List(I)
       End If
    Next I
End Sub

Sun, 22 Jul 2001 03:00:00 GMT  
 Question: Deleting Multiple Items in ListBox??
Private Sub Command1_Click()
Dim i, z As Integer

    z = lstLeft.ListCount - 1

    For i = 0 To z
        If i > z Then
            Exit For
        End If
        If lstLeft.Selected(i) = True Then
            lstRight.AddItem List1.List(i)
            lstLeft.RemoveItem i
            z = lstLeft.ListCount - 1
        End If
    Next i
End Sub

Mon, 23 Jul 2001 03:00:00 GMT  
 Question: Deleting Multiple Items in ListBox??
I want to take the time to say thanks for everybody who replied to me
privately or via this newsgroup.  Some people came up with a really funky
idea how to solve it, but hey they work!  So thanks for your contribution.


Mon, 23 Jul 2001 03:00:00 GMT  
 [ 4 post ] 

 Relevant Pages 

1. deleting multiple item on listbox

2. ListBox (w/Checkboxes)....Deleting Multiple-Selected Items

3. ListBox (w/Checkboxes)....Deleting Multiple-Selected Items

4. Delete Item in an array which corresponds to Itemsselected in multiselect listbox

5. Help...ListBox Deleting Multi-Selected Items

6. How To:Deleting item from ListBox;vb6

7. Selection Of Multiple Items In Listbox/Combo Box And Inserting Them Into SQL Server

8. Multiple items in ListBox

9. Copy Multiple Items From Listbox to Clipboard

10. Retreiving multiple ListBox Items

11. Listbox with multiple items in it?

12. Multiple items in ListBox


Powered by phpBB® Forum Software