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
|
Public Function MiseEnClasse(Valeur As Variant, Pas As Variant)
' attention :
' pas de 1 : maximum 51
' pas de 10 : maximum : 210
' pas de 0.5 : maximum : 15.5
' pas de 50 : maximum : 500
Dim BorneInf, BorneSup As Variant
Dim I As Integer
If VarType(Valeur) = vbNull Then
MiseEnClasse = "[0]"
Exit Function
End If
' gestion de la valeur 0
If Valeur = 0 Or Valeur < 0 Then
MiseEnClasse = "[0]"
Exit Function
End If
If Pas = 1000 Then
BorneInf = Array(-1, 0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000)
BorneSup = Array(0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000)
End If
If Pas = 50 Then
BorneInf = Array(-1, 0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500)
BorneSup = Array(0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500)
End If
If Pas = 10 Then
BorneInf = Array(-1, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200)
BorneSup = Array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210)
End If
If Pas = 5 Then
BorneInf = Array(-1, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100)
BorneSup = Array(0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 200)
End If
If Pas = 1 Then
BorneInf = Array(-1, 0, 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)
BorneSup = Array(0, 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)
End If
If Pas = 0.5 Then
BorneInf = Array(-1, 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.5, 13, 13.5, 14, 14.5, 15)
BorneSup = Array(0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.5, 13, 13.5, 14, 14.5, 15, 15.5)
End If
If Pas = 0.1 Then '10/01/2006
BorneInf = Array(-0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1#, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2#, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3)
BorneSup = Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1#, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2#, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3, 3.5)
End If
I = 1
Do Until Valeur >= BorneInf(I) And Valeur < BorneSup(I)
I = I + 1
If Pas = 1 And I = 51 Then GoTo sort
If Pas = 10 And I = 21 Then GoTo sort
If Pas = 5 And I = 21 Then GoTo sort
If Pas = 0.5 And I = 21 Then GoTo sort
If Pas = 0.1 And I = 21 Then GoTo sort
Loop
sort:
If Pas = 10 And I = 12 Then BorneSup(12) = 100
If Pas = 10 And I = 12 Then
MiseEnClasse = "[" & str(BorneInf(I)) & "]"
Exit Function
End If
MiseEnClasse = "[" & str(BorneInf(I)) & ";" & str(BorneSup(I)) & "["
End Function |
Partager