Avoir un point ou une virgule dans une textbox
Bonjour
J'ai récupéré se code qui me permet de prendre en compte dans un nombre un point ou une virgule
Ma TextBox1 écrit dans une cellule de mon fichier EXCEL
Mon problème c'est que quand j'écris 123.12 ou 123,12 cela fonctionne
mais quand j'écris 123.123 ou 123,123 cela m'écrit 123123
Comment puis je avoir 3 chiffre après la virgule?
Merci
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
Option Explicit
Const entrees_decimales_permises = ".,0123456789" & vbCr & vbBack
Const Point = "."
Const Virgule = ","
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 |
Comment puis je avoir 3 chiffre après la virgule?
Bonjour rdurupt
peux tu développer
Code:
v= round(10.123456789,3)
v ?
merci
Comment puis je avoir 3 chiffre après la virgule?
Merci mais quand tu écris v= a quoi correspond-il si c'est une variable a qui doit on la déclarer?
Merci
Comment puis je avoir 3 chiffre après la virgule?
Merci rdurupt et kiki29
Cela fonctionne
Bonne journée