I have two listboxes List1 has the numbers from 11 to 99. List2 can hold any of these numbers depending on the user.
My Question is, how can I remove the numbers in list2 from List1 with a commandbutton.
Thanks for your help. Andyb
Printable View
I have two listboxes List1 has the numbers from 11 to 99. List2 can hold any of these numbers depending on the user.
My Question is, how can I remove the numbers in list2 from List1 with a commandbutton.
Thanks for your help. Andyb
???
??? Don't know what ya want!?!Code:Private Sub Command1_Click()
List1.RemoveItem 5 'the 6th item in the listbox
List1.RemoveItem 5 'the 6th item in the listbox
End Sub
I want to remove all the items in list2 from list1.
Try the following.
Code:Private Sub Command1_Click()
For I = 0 To List2.ListCount - 1
For X = 0 To List1.ListCount - 1
If List2.List(I) = List1.List(X) Then List1.RemoveItem (X)
Next X
Next I
End Sub
Private Sub Form_Load()
'Populate List1 with 20 items
For I = 0 To 20
List1.AddItem I
Next I
'Populate List2 with 10 items
For I = 0 To 10
List2.AddItem I
Next I
End Sub