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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
| 'MISE A JOUR DES VALEURS DEPUIS LA COMBOBOX1
Private Sub ComboBox1_Click()
MajLiset Me.ComboBox1, Me.ComboBox2, Me.ComboBox3
'pour trier l'affichage
Dim Lig
Dim Col
Dim clé() As String, index() As Long, a(), b()
a = Me.ListBox1.List
ReDim b(LBound(a) To UBound(a), LBound(a, 2) To UBound(a, 2))
ReDim clé(LBound(a) To UBound(a, 1))
ReDim index(LBound(a) To UBound(a, 1))
For i = LBound(a) To UBound(a, 1)
clé(i) = a(i, 0) & a(i, 1): index(i) = i
Next i
Call Tri(clé(), index(), LBound(a), UBound(clé))
For Lig = LBound(clé) To UBound(clé)
For Col = LBound(a, 2) To UBound(a, 2): b(Lig, Col) = a(index(Lig), Col): Next Col
Next Lig
Me.ListBox1.List = b
End Sub
'MISE A JOUR DES VALEURS DEPUIS LA COMBOBOX2
Private Sub ComboBox2_Click()
MajLiset Me.ComboBox1, Me.ComboBox2, Me.ComboBox3
'pour trier l'affichage
Dim Lig
Dim Col
Dim clé() As String, index() As Long, a(), b()
a = Me.ListBox1.List
ReDim b(LBound(a) To UBound(a), LBound(a, 2) To UBound(a, 2))
ReDim clé(LBound(a) To UBound(a, 1))
ReDim index(LBound(a) To UBound(a, 1))
For i = LBound(a) To UBound(a, 1)
clé(i) = a(i, 0) & a(i, 1): index(i) = i
Next i
Call Tri(clé(), index(), LBound(a), UBound(clé))
For Lig = LBound(clé) To UBound(clé)
For Col = LBound(a, 2) To UBound(a, 2): b(Lig, Col) = a(index(Lig), Col): Next Col
Next Lig
Me.ListBox1.List = b
End Sub
'MISE A JOUR DES VALEURS DEPUIS LA COMBOBOX3
Private Sub ComboBox3_Click()
MajLiset Me.ComboBox1, Me.ComboBox2, Me.ComboBox3
'pour trier l'affichage
Dim Lig
Dim Col
Dim clé() As String, index() As Long, a(), b()
a = Me.ListBox1.List
ReDim b(LBound(a) To UBound(a), LBound(a, 2) To UBound(a, 2))
ReDim clé(LBound(a) To UBound(a, 1))
ReDim index(LBound(a) To UBound(a, 1))
For i = LBound(a) To UBound(a, 1)
clé(i) = a(i, 0) & a(i, 1): index(i) = i
Next i
Call Tri(clé(), index(), LBound(a), UBound(clé))
For Lig = LBound(clé) To UBound(clé)
For Col = LBound(a, 2) To UBound(a, 2): b(Lig, Col) = a(index(Lig), Col): Next Col
Next Lig
Me.ListBox1.List = b
End Sub
Sub Tri(clé() As String, index() As Long, gauc, droi) ' Quick sort
Dim ref
Dim g
Dim d
Dim temp
ref = clé((gauc + droi) \ 2)
g = gauc: d = droi
Do
Do While clé(g) < ref: g = g + 1: Loop
Do While ref < clé(d): d = d - 1: Loop
If g <= d Then
temp = clé(g): clé(g) = clé(d): clé(d) = temp
temp = index(g): index(g) = index(d): index(d) = temp
g = g + 1: d = d - 1
End If
Loop While g <= d
If g < droi Then Call Tri(clé, index, g, droi)
If gauc < d Then Call Tri(clé, index, gauc, d)
End Sub |