j'ai ajouté ca dans la partie declaration:
Private Const LB_FINDSTRINGEXACT = &H1A2
Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
a toi de choisir entre ces deux fonctions :
Public Function AddDistinct(List As ListBox, ByVal Item As String) As Boolean
If SendMessage(List.hWnd, LB_FINDSTRINGEXACT, 0, ByVal Item) = -1 Then
List.AddItem Item
AddDistinct = True
End If
End Function
qui te permet de ne pas ajouter de doublons.
et
Public Sub RemoveDuplicates(List As ListBox)
Dim i As Integer
Dim k As Integer
Do
DoEvents
For i = 0 To List1.ListCount - 1
k = SendMessage(List.hWnd, LB_FINDSTRINGEXACT, i, ByVal List.List(i))
If k > i Then
List.RemoveItem k
Exit For
End If
Next i
If k = 0 Then Exit Do
Loop While True
End Sub
qui te permet de les enlever