For example if I have SMTP_HOST twice in listbox, how can i eliminate on of them so basically i need to remove all double entries in my listbox leaving only those that are different
Thank You
Printable View
For example if I have SMTP_HOST twice in listbox, how can i eliminate on of them so basically i need to remove all double entries in my listbox leaving only those that are different
Thank You
try this code. It makes all entries unique
private Sub Command1_Click()
List1.AddItem "test"
List1.AddItem "test"
List1.AddItem "test"
List1.AddItem "second"
List1.AddItem "second"
List1.AddItem "second"
List1.AddItem "second"
List1.AddItem "second"
List1.AddItem "third"
List1.AddItem "third"
End Sub
Sub makeUnique(l as ListBox)
Dim i as Integer
for i = l.ListCount - 1 to 0 step -1
If l.List(i) = l.List(i - 1) then
l.RemoveItem i
End If
next i
End Sub
...sample assumes "Sorted = True" for the listbox...
isnt it even better if sorted=false?
If I set sorted = false then it won't give me a right solution, I need to have it set to True.