Tools Links Login

[Fast] Remove Duplicates From A Listbox

Removes Duplicates From A Listbox. Fastest one i've seen.

Original Author: Richard V.

Assumptions

I did NOT write this code, I just felt like putting it up.

Code

Sub RemoveDuplicates(ListBox As ListBox)
Dim Col As New Collection
Dim i As Long
On Error Resume Next
If ListBox.ListCount > 1 Then
For i = 0 To ListBox.ListCount - 1
Col.Add ListBox.List(i), ListBox.List(i)
Next
ListBox.Clear
For i = 1 To Col.Count
ListBox.AddItem Col.Item(i)
Next
Set Col = Nothing
End If
End Sub

About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 96 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.