hi all,
I have a list box with a few 1000s items in it.. there are many duplicate items in it.. some several times actaully.
how can I remove all duplicates from the list.
thanks a lot guys!
Abe
Printable View
hi all,
I have a list box with a few 1000s items in it.. there are many duplicate items in it.. some several times actaully.
how can I remove all duplicates from the list.
thanks a lot guys!
Abe
I'd suggest passing all the elements into an array, use some sort of bubble sort to put only unique items into another array and finally, after deleting all elements in the combo box, populate the combo box with the entries from the second array
How is this data being loaded to the listbox?
thanks guys
it will be populated via database..
however.. at the moment I just put a bunch of "list1.additem XXXX" in the load form event as a demo...
any advise?
cheers
Abe
A simple little loop should do the trick nicely. :)VB Code:
Private Sub Command1_Click() Dim i As Long Dim j As Long With List1 For i = 0 To .ListCount - 1 For j = .ListCount To (i + 1) Step -1 If .List(j) = .List(i) Then .RemoveItem j End If Next Next End With End Sub
cant you just filter out the duplicates when you query the db?Quote:
Originally posted by Abdulrahman
thanks guys
it will be populated via database..
however.. at the moment I just put a bunch of "list1.additem XXXX" in the load form event as a demo...
any advise?
cheers
Abe
Couldn't you load as DISTNCT?Quote:
Originally posted by Abdulrahman
thanks guys
it will be populated via database..
however.. at the moment I just put a bunch of "list1.additem XXXX" in the load form event as a demo...
any advise?
cheers
Abe
Thanks a lot!!!
damn why did I not think of that!
my brain gets dizzy when I get into nested loops....
:D
Abe