Private Sub textBox1_Change()
On Error Resume Next
Dim pos As Integer
' on remplace le point par une virgule
If (Right(TextBox1, 1)) = "." Then TextBox1.Value = Mid(TextBox1.Value, 1, Len(TextBox1.Value) - 1) & ","
' on compte le nombre de chiffre après la virgule
pos = InStr(1, TextBox1.Value, ",")
If pos > 0 And Len(Mid(TextBox1.Value, pos + 1)) > 2 Then' si > 2 alors on supprime la valeur
TextBox1 = Left(TextBox1, Len(TextBox1) - 1)
End If
' vérification des valeurs
If Not IsNumeric(Right(TextBox1, 1)) And Right(TextBox1, 1) <> "," Then
MsgBox "Le caractere saisi n'est pas valide"
TextBox1 = Left(TextBox1, Len(TextBox1) - 1)
End If
End Sub