Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Multiselection

5 réponses
Avatar
Jean-Michel
Bonjour,

Comment je peux récupérer le numero de plusieurs lignes d'une listbox au cas
ou l'operateur selectionne plusieurs lignes grace à ctrl !

Merci pour votre aide !

Jean-Michel

5 réponses

Avatar
François Picalausa
Bonjour/soir,

Jette un oeil à la propriété Select.
Dim ItemsLeft As Long, i as long
ItemsLeft = List.SelCount

Do While ItemsLeft And i < List.ListCount
If List.Selected(i) Then
ItemsLeft =ItemsLeft -1
Msgbox List.List(i)
Msgbox "Encore " & ItemsLeft & "éléments restant à trouver"
End If
i = i + 1
Loop

--
François Picalausa (MVP VB)
http://faq.vb.free.fr --- http://msdn.microsoft.com
http://apisvb.europe.webmatrixhosting.net

"Jean-Michel" a écrit dans le
message de news:
Bonjour,

Comment je peux récupérer le numero de plusieurs lignes d'une listbox
au cas ou l'operateur selectionne plusieurs lignes grace à ctrl !

Merci pour votre aide !

Jean-Michel


Avatar
ng
Salut,

Le controle doit déjà être en MutliSelect = True, il suffit alors de boucler
les item :

Private Sub Command1_Click()
Dim i As Integer
For i = 0 To List1.ListCount - 1
If List1.Selected(i) = True Then
MsgBox "L'item #" & (i + 1) & " est sélectionné !"
End If
Next
End Sub



--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/
http://apisvb.europe.webmatrixhosting.net/

Jean-Michel a écrit :

Bonjour,

Comment je peux récupérer le numero de plusieurs lignes d'une listbox
au cas ou l'operateur selectionne plusieurs lignes grace à ctrl !

Merci pour votre aide !

Jean-Michel


Avatar
Jean-Michel
merci je vais essayer

"ng" a écrit dans le message de
news:
Salut,

Le controle doit déjà être en MutliSelect = True, il suffit alors de


boucler
les item :

Private Sub Command1_Click()
Dim i As Integer
For i = 0 To List1.ListCount - 1
If List1.Selected(i) = True Then
MsgBox "L'item #" & (i + 1) & " est sélectionné !"
End If
Next
End Sub



--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/
http://apisvb.europe.webmatrixhosting.net/

Jean-Michel a écrit :

> Bonjour,
>
> Comment je peux récupérer le numero de plusieurs lignes d'une listbox
> au cas ou l'operateur selectionne plusieurs lignes grace à ctrl !
>
> Merci pour votre aide !
>
> Jean-Michel




Avatar
ng
ReSalut,

Petite correction :

Private Sub Command1_Click()
Dim i As Integer
For i = 0 To List1.ListCount - 1
If List1.Selected(i) Then
MsgBox "L'item #" & (i + 1) & " est sélectionné !"
End If
Next
End Sub


--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/
http://apisvb.europe.webmatrixhosting.net/

ng a écrit :

Salut,

Le controle doit déjà être en MutliSelect = True, il suffit alors de
boucler les item :

Private Sub Command1_Click()
Dim i As Integer
For i = 0 To List1.ListCount - 1
If List1.Selected(i) = True Then
MsgBox "L'item #" & (i + 1) & " est sélectionné !"
End If
Next
End Sub




Bonjour,

Comment je peux récupérer le numero de plusieurs lignes d'une listbox
au cas ou l'operateur selectionne plusieurs lignes grace à ctrl !

Merci pour votre aide !

Jean-Michel




Avatar
Jean-Michel
J'ai un probleme, c'est que ca me dit erreur de compilation sur
List1.ListCount
Pareil pour SelCount et ListCound, il ne coonnait pas ces propriété, pk ?

Merci !

"ng" a écrit dans le message de
news:%
ReSalut,

Petite correction :

Private Sub Command1_Click()
Dim i As Integer
For i = 0 To List1.ListCount - 1
If List1.Selected(i) Then
MsgBox "L'item #" & (i + 1) & " est sélectionné !"
End If
Next
End Sub


--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/
http://apisvb.europe.webmatrixhosting.net/

ng a écrit :

> Salut,
>
> Le controle doit déjà être en MutliSelect = True, il suffit alors de
> boucler les item :
>
> Private Sub Command1_Click()
> Dim i As Integer
> For i = 0 To List1.ListCount - 1
> If List1.Selected(i) = True Then
> MsgBox "L'item #" & (i + 1) & " est sélectionné !"
> End If
> Next
> End Sub
>
>
>
>
>> Bonjour,
>>
>> Comment je peux récupérer le numero de plusieurs lignes d'une listbox
>> au cas ou l'operateur selectionne plusieurs lignes grace à ctrl !
>>
>> Merci pour votre aide !
>>
>> Jean-Michel