Option Explicit
Sub textbox_KeyPress(txtb, KeyAscii As MSForms.ReturnInteger)
Dim V$, X&, forme$
If KeyAscii = 46 Then KeyAscii = 44
With txtb
V = .Value & Chr(KeyAscii)
If Len(V) Then If InStr("+-", Left(V, 1)) = 0 Then KeyAscii = 0: MsgBox "le signe ""+"" ou ""-"" est obligatoire" 'on vire si + ou moins n'est pas le premier
X = InStr(V, ",")
forme = Left(V, 1) & Application.Rept("#", Len(V) - 1): If X > 2 Then Mid(forme, X) = "."
If Len(V) > 1 And Not IsNumeric(Format(Right(V, Len(V) - 1), forme)) Then KeyAscii = 0
End With
End Sub