Bonjour toutes et tous,
J'ai testé cela à l'air de fonctionner pour l'userform4
NOTE: que l'on saisisse au clavier la touche '.' du pavé numérique se place systématiquement en ','
à placer au début :
Option Explicit
Const entrees_decimales_permises = ".,0123456789" & vbCr & vbBack
Const Point = "."
Const Virgule = ","
-pour les textbox(s) 1, 2, 3 et 4 de ton usf4
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = Asc(Point) Then
If InStr(TextBox1, Virgule) = 0 Then
KeyAscii = Asc(Virgule)
Else
KeyAscii = 0
End If
ElseIf InStr(entrees_decimales_permises, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
ElseIf InStr(TextBox1, Virgule) > 0 And KeyAscii = Asc(Virgule) Then
KeyAscii = 0
End If
End Sub
Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = Asc(Point) Then
If InStr(TextBox2, Virgule) = 0 Then
KeyAscii = Asc(Virgule)
Else
KeyAscii = 0
End If
ElseIf InStr(entrees_decimales_permises, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
ElseIf InStr(TextBox2, Virgule) > 0 And KeyAscii = Asc(Virgule) Then
KeyAscii = 0
End If
End Sub
Private Sub TextBox3_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = Asc(Point) Then
If InStr(TextBox3, Virgule) = 0 Then
KeyAscii = Asc(Virgule)
Else
KeyAscii = 0
End If
ElseIf InStr(entrees_decimales_permises, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
ElseIf InStr(TextBox3, Virgule) > 0 And KeyAscii = Asc(Virgule) Then
KeyAscii = 0
End If
End Sub
Private Sub TextBox4_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = Asc(Point) Then
If InStr(TextBox4, Virgule) = 0 Then
KeyAscii = Asc(Virgule)
Else
KeyAscii = 0
End If
ElseIf InStr(entrees_decimales_permises, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
ElseIf InStr(TextBox4, Virgule) > 0 And KeyAscii = Asc(Virgule) Then
KeyAscii = 0
End If
End Sub
et faire ceci pour les autres usfs de text textbox en n'oubliant pas de mettre option explicit et const...
crdlt,
André