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 33 34 35 36 37 38 39 40 41
| Option Explicit
Dim nb As Integer
Private Sub Command4_Click()
Dim choses
choses = Array("pommes", "poires", "pêches", "abricots", "cerises")
Dim i As Integer, debut As Integer, fin As Integer, j As Integer, toto As String
reslst.Clear
reslst.Visible = False
nb = UBound(choses) + 1
For i = 1 To nb
reslst.AddItem i
Next
debut = 0
fin = reslst.ListCount - 1
Do
For i = debut To fin
For j = Val(reslst.List(i)) + 1 To nb
toto = j & "-" & reslst.List(i)
If Right(toto, 1) <> "-" Then
reslst.AddItem toto
Else
Exit Do
End If
Next
Next
debut = fin + 1
fin = reslst.ListCount
Loop
retablissons choses, reslst
reslst.Visible = True
MsgBox reslst.ListCount & " cocktails"
End Sub
Private Sub retablissons(c As Variant, r As Control)
Dim t, i As Integer, j As Integer
For i = 0 To r.ListCount - 1
t = Split(r.List(i), "-")
For j = 0 To UBound(t)
r.List(i) = Replace(r.List(i), t(j), c(Val(t(j) - 1)))
Next
Next
End Sub |
Partager