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
| Option Explicit
Const entrees_decimales_permises = ".,0123456789" & vbCr & vbBack
Const Point = "."
Const Virgule = ","
Private Sub TextBox5_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = Asc(Point) Then
If InStr(TextBox5, Virgule) = 0 Then
KeyAscii = Asc(Virgule)
Else
KeyAscii = 0
End If
ElseIf InStr(entrees_decimales_permises, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
ElseIf InStr(TextBox5, Virgule) > 0 And KeyAscii = Asc(Virgule) Then
KeyAscii = 0
End If
End Sub
Private Sub TextBox5_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TextBox5.Text = Format(TextBox5, "#,##0.00")
' si TextBox5 vide
If IsNumeric(TextBox5) Then
ActiveCell = CDbl(TextBox5)
End If
End Sub |