LbDupeDel



Public Declare Function SendMessageByString Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As String) As Long

Public Const LB_FINDSTRINGEXACT = &H1A2

Function LBDupe(lpBox As ListBox) As Integer
Dim nCount As Integer, nPos1 As Integer, nPos2 As Integer
Dim nDelete As Integer
Dim sText As String

If lpBox.ListCount < 3 Then
LBDupe = 0
Exit Function
End If

For nCount = 0 To lpBox.ListCount - 1
Do
DoEvents2
sText = lpBox.list(nCount)
'had to update this line, sorry

nPos1 = SendMessageByString(lpBox.hwnd, _
LB_FINDSTRINGEXACT, nCount, sText)
nPos2 = SendMessageByString(lpBox.hwnd, _
LB_FINDSTRINGEXACT, nPos1 + 1, sText)
If nPos2 = -1 Or nPos2 = nPos1 Then Exit Do
lpBox.RemoveItem nPos2
nDelete = nDelete + 1
Loop
Next nCount
LBDupe = nDelete
End Function

(lbdupedel.html)- by Paolo Puglisi - Modifica del 25/3/2019