Merci beaucoup, mais j'ai un message d'erreur : "Type d'argument ByRef incompatible" sur "schoixliste1" de cette ligne :
If In_Listbox(ListboxQualif2.List, 0, schoixliste1) Then
Voici le code en entier :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| Function In_Listbox(i As Long, lblst As Variant, Col As Integer, recherche As Variant) As Boolean
In_Listbox = False
For i = LBound(lblst) To UBound(lblst)
If lblst(i, Col) = recherche Then 'Si valeur trouvée
In_Listbox = True
Exit For
End If
Next
End Function
Private Sub FlècheAjout_click()
Dim i As Long
For i = ListboxQualif.ListCount - 1 To 0 Step -1
schoixliste1 = ListboxQualif.Selected(i)
If In_Listbox(ListboxQualif2.List, 0, schoixliste1) Then
MsgBox "Cet élément est déjà présent": Exit Sub
End If
If ListboxQualif.Selected(i) = True Then
ListboxQualif2.AddItem ListboxQualif.List(i)
ListboxQualif.Selected(i) = True
ListboxQualif.RemoveItem i
End If
Next i
End Sub |
Dans la fonction entre parenthèse j'ai rajouté "i As Long" car le i n'était pas déclaré, je ne sais pas s'il fallait bien faire comme ça :s
Merci
Partager