Reputation: 2473
I am trying to remove items from a listbox based on the items on another listbox, this seems simple but apparently I can't get my code to work, please advice. Thanks.
Dim listRemove As New List(Of ListItem)
For Each item As ListItem In QualOutletToBox.Items
listRemove.Add(item) ' Collect items from ListBox A
Next
For Each item In listRemove
QualOutletFromBox.Items.Remove(item) ' Remove items from ListBox B based on ListBox A
Next
Upvotes: 0
Views: 357
Reputation: 44931
Regarding the follow-on question, yes, there is a much less resource intensive method, a single loop:
For Each item As ListItem In QualOutletToBox.Items
QualOutletFromBox.Items.Remove(item) ' Remove items from ListBox B based on ListBox A
Next
Upvotes: 3