Bonsoir à tous,
J'utilise un dictionary, mais on peut aussi utiliser un array, pour passer les variables.
Dim oDico, k
Set oDico = CreateObject("Scripting.Dictionary")
oDico.Add k, "a=6" : k = k + 1
oDico.Add k, "b=2" : k = k + 1
oDico.Add k, "c=3" : k = k + 1
oDico.Add k, "d=7" : k = k + 1
bpermute = True 'Il faut au moins parcourir une fois
Do While bpermute = True 'On tourne tant que l'on bouge des valeurs
bpermute = False
For i = oDico.Count To 1 Step -1
If Len(oDico(i)) > 1 Then
For j = 0 To i - 1
If Len(oDico(j)) > 1 Then
If Split(oDico(j), "=")(1) > Split(oDico(j + 1), "=")(1) Then
cprovisoire = oDico(j) 'On inverse les deux chaines
oDico(j) = oDico(j + 1) 'bis
oDico(j + 1) = cprovisoire 'bis
bpermute = True
End If
End If
Next
End If
Next
Loop
Dim liste
For i = 0 To oDico.Count
If Len(oDico(i)) > 1 Then liste = oDico(i) &vbCrLf& liste
Next
MsgBox liste
jean-marc