Remove Duplicate Items in Listbox
Hello, Im trying to remove duplicate items in listbox.
My list box looks like this.
row 1
row 1
row 2
row 2
row 3
row 3
row 4
row 4
And I would like to remove the duplicated row. How can I do this?
I tried Me.ListBox1.Items.Remove("row 1") but that will remove both row 1's.
Thankz. :)
Re: Remove Duplicate Items in Listbox
How did the data get into the ListBox in the first place?
Re: Remove Duplicate Items in Listbox
I think where jmcilhinney is going is that you can check to see if the item is in the list before you add it.
Hey jmcilhinney are you watching our Super Bowl? What time is it on there?
Re: Remove Duplicate Items in Listbox
Well I extract links from a web page and some web pages have duplicated URLs. I cant find a way to check to see if the URL is in the listbox before adding?
:confused:
Re: Remove Duplicate Items in Listbox
You can check with findstringexact.
Code:
'if FindStringExact returns -1 then the item doesnt exist in the listbox
If ListBox1.FindStringExact(yourstring) = -1 Then
ListBox1.Items.Add(yourstring)
End If
Casey.