I prefer the API route, but they both work fine...
VB Code:
Option Explicit
Private Declare Function SendMessageStr Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As String) _
As Long
Private Const LB_ERR = (-1)
Private Const LB_FINDSTRINGEXACT = &H1A2
Private Sub Command1_Click()
RemoveDuplicates List1
End Sub
Private Sub RemoveDuplicates(lst As ListBox)
Dim lPos As Long, x As Long
For x = (lst.ListCount - 1) To 0 Step (-1)
lPos = SendMessageStr(lst.hwnd, LB_FINDSTRINGEXACT, _
LB_ERR, lst.List(x))
While ((lPos <> LB_ERR) And (lPos <> x))
Call lst.RemoveItem(lPos)
lPos = SendMessageStr(lst.hwnd, LB_FINDSTRINGEXACT, _
LB_ERR, lst.List(x))
Wend
Next
End Sub