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
| Private Sub TextBox_ht_Exit(ByVal Cancel As MSForms.ReturnBoolean)
'Si la valeur de textbox_ht est un nombre sans virgule alors on rajoute la virgule et deux 0
Dim vResult_ht As Variant, montant As String
If TextBox_ht.Value = "" Then
Else
'vResult_ht = Replace(TextBox_ht.Value, ".", ",")
'vResult_ht = CDbl(vResult_ht)
vResult_ht = CDbl(Val(TextBox_ht.Value)) 'passage d'une chaine string en une valeur de type double si un nombre est rentré dans la textbox
TextBox_ht = IIf(IsNumeric(vResult_ht), Format(vResult_ht, "###0.00"), "")
TextBox_ht = Replace(TextBox_ht, ",", ".")
End If
If (OptionButton_lot.Value = True) Then
montant_ht = "lot 1 : " + TextBox_ht + ""
ElseIf (OptionButton_bon_commande.Value = True) Then
montant_ht = "min : " + TextBox_ht + ""
Else
montant_ht = TextBox_ht
End If
End Sub
Private Sub TextBox_ht_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'Seule une valeur numérique peut être entré
If InStr("0123456789.", Chr(KeyAscii)) = 0 Then KeyAscii = 0
'Si le caractère saisi est le 1er et qu'il s'agit d'un point alors j'ajoute 0 devant
If Len(TextBox_ht) = 1 And TextBox_ht = "." Then TextBox_ht = "0."
'Si un point est déjà dans la chaine on ne peut pas en taper un autre
If InStr(TextBox_ht.Value, ".") <> 0 And Chr(KeyAscii) = "." Then KeyAscii = 0
'S'il existe un point dans le TextBox : InStr(TextBox_ht.Value, ".") <> 0
'et que la longueur de la chaine contenue dans le textbox : Len(TextBox_ht.Value)
'est supérieure à la place du . dans la chaine + 1 > InStr(TextBox_ht.Value, ".") + 1
'alors on annule la saisie : Then KeyAscii = 0
If InStr(TextBox_ht.Value, ".") <> 0 And Len(TextBox_ht.Value) > InStr(TextBox_ht.Value, ".") + 1 Then KeyAscii = 0
End Sub
Private Sub TextBox_ht_max_Exit(ByVal Cancel As MSForms.ReturnBoolean)
'Si la valeur de textbox_ht est un nombre sans virgule alors on rajoute la virgule et deux 0
Dim vResult_ht_max As Variant, montant_ht_max As String
If TextBox_ht_max.Value = "" Then
Else
'vResult_ht_max = Replace(TextBox_ht_max.Value, ".", ",")
'vResult_ht_max = CDbl(vResult_ht_max)
vResult_ht_max = CDbl(Val(TextBox_ht_max.Value))
TextBox_ht_max = IIf(IsNumeric(vResult_ht_max), Format(vResult_ht_max, "###0.00"), "")
TextBox_ht_max = Replace(TextBox_ht_max, ",", ".")
End If
If (OptionButton_lot.Value = True) Then
montant_ht_max = "lot 2 : " + TextBox_ht_max + ""
ElseIf (OptionButton_bon_commande.Value = True) Then
montant_ht_max = "max : " + TextBox_ht_max + ""
End If
End Sub
Private Sub TextBox_ht_max_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'Seule une valeur numérique peut être entré
If InStr("0123456789.", Chr(KeyAscii)) = 0 Then KeyAscii = 0
'Si le caractère saisi est le 1er et qu'il s'agit d'un point alors j'ajoute 0 devant
If Len(TextBox_ht_max) = 1 And TextBox_ht_max = "." Then TextBox_ht_max = "0."
'Si un point est déjà dans la chaine on ne peut pas en taper un autre
If InStr(TextBox_ht_max.Value, ".") <> 0 And Chr(KeyAscii) = "." Then KeyAscii = 0
'S'il existe un point dans le TextBox : InStr(TextBox_ht.Value, ".") <> 0
'et que la longueur de la chaine contenue dans le textbox : Len(TextBox_ht.Value)
'est supérieure à la place du . dans la chaine + 1 > InStr(TextBox_ht.Value, ".") + 1
'alors on annule la saisie : Then KeyAscii = 0
If InStr(TextBox_ht_max.Value, ".") <> 0 And Len(TextBox_ht_max.Value) > InStr(TextBox_ht_max.Value, ".") + 1 Then KeyAscii = 0
End Sub |
Partager