Friday, August 27, 2010

VB6.0 Remove Duplicates From ListBox

Private Sub Command6_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

Dim k As Long
Dim l As Long
With List2
For k = 0 To .ListCount - 1
For l = .ListCount To (k + 1) Step -1
If .List(l) = .List(k) Then
.RemoveItem l
End If
Next
Next
End With

End Sub