ou encore les API........
Private Declare Function SendMessage 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_FINDSTRINGEXACT = &H1A2
Private Sub Form_Load()
AjouteItem List1, "test"
AjouteItem List1, "a"
AjouteItem List1, "test"
End Sub
Public Sub AjouteItem(ListBox As ListBox, Item As String, Optional EmpecheDoublons As Boolean = True)
Dim Id
Id = GetIndex(ListBox, Item)
If Not EmpecheDoublons Or Not (EmpecheDoublons And Id <> -1) Then
ListBox.AddItem (Item)
End If
End Sub
Function GetIndex(ListBox As ListBox, Item As String) As Long
'renvoie l'inddice de l'item dans le listbox. -1 si non trouvé.
' le parametre -1 donne l'indice de depart , utilisé dans la recherche.
GetIndex = SendMessage(ListBox.hwnd, LB_FINDSTRINGEXACT, -1, Item)
End Function
-----------------------------------------------------------------------
By Renfield
thomas_reynald@msn.com
Aucune touche n'a été bléssée lors de la saisie de ce texte..........