
12-15-2003, 10:03 AM
|
 |
Obsessive OPtimizer
Administrator * Guru *
|
|
Join Date: Jun 2002
Location: Debug Window
Posts: 13,685
|
|
gprinsloo makes a good point, in that it's better to not add duplicates, rather than add them and then remove. You can check if an item exists more quickly using SendMessage and LB_FINDSTRINGEXACT.
If you have a combo/list that already contains dups for some reason, and it is sorted, you can simply do this to remove them:
Code:
Dim i As Long
For i = Combo1.ListCount - 1 to 1 Step -1
If Combo1.List(i) = Combo1.List(i - 1) Then ' add UCase$ or LCase$ if you care about case
Combo1.RemoveItem i
End If
Next i
|
|