Hey i am trying to remove duplicate items from 2 listboxes.... i have the code to remove duplicate items from one list box...i'm trying to build a database of names and i dont want the names to be on there twice. So I'm wanting one list to be the database or names and the other list to be new names.. Lets say i have the database list that has 1,000 names and the other list has 200 names...I want to have a button that when it is clicked it will remove any names from the second list if it is already in the database list....here is the code i have to remove duplicates
Public Sub RemoveDuplicateItem(ByVal listboxName As ListBox)
listboxName.Sorted = True
listboxName.Refresh()
Dim index As Integer
Dim itemcount As Integer = listboxName.Items.Count
If itemcount > 1 Then
Dim lastitem As String = listboxName.Items(itemcount - 1)
For index = itemcount - 2 To 0 Step -1
If listboxName.Items(index) = lastitem Then
listboxName.Items.RemoveAt(index)
Else
lastitem = listboxName.Items(index)
End If
Next
End If
End Sub
Any suggestions or a better way to do this?


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks