Private colList As Collection
Private Sub cmdRemDuplicate_Click()
Dim nC As Integer
Set colList = New Collection
For nC = 0 To List1.ListCount - 1
Call AddToCollection(List1.List(nC))
Next nC
List1.Clear
For nC = 1 To colList.Count
Call List1.AddItem(colList(nC))
Next nC
End Sub
Private Sub Form_Load()
List1.AddItem "Test1"
List1.AddItem "Test1"
List1.AddItem "An error also occurs if a specified key duplicates the key for an existing member of the collection."
List1.AddItem "An error also occurs if a specified key duplicates the key for an existing member of the collection."
List1.AddItem "Test3"
List1.AddItem "Test4"
List1.AddItem "Test4"
End Sub
Private Sub AddToCollection(ByVal sText As String)
On Error GoTo Duplicate
Call colList.Add(sText, sText)
Exit Sub
Duplicate:
'Item already exists, won't be added to collection
End Sub