I have a textbox in userform which will be filled only with digits, commas, or dots. I know how to restrict use of only those characters. My question is it possible to limit filling value to 2 digits after coma/dot?
So when I enter value like: 1023,456
it would not let me type 6
without any action.
Editted:
I can't get this... I tried testing codes given here: Regex to match 2 digits, optional decimal, two digits However it matches too many things. When I type more then 2 digits after comma it still matches as good string. I used for example:
\d{0,2}(\,\d{1,2})?
[0-9]?[0-9]?(\,[0-9][0-9]?)?
What I am doing wrong?
Private Sub netto_Change()
Dim regEx As New VBScript_RegExp_55.RegExp
regEx.Pattern = "\d{0,2}(\,\d{1,2})?"
If regEx.Test(netto.Value) = True Then MsgBox ("It works!")
End Sub
Edit 2:
Okay, I am really close I got this code: ^[0-9]+[\,\.]?[0-9]?[0-9]$
but one thing is missing. This pattern should also apply to string like: 321,
with comma\dot at the end but without anything after that.
What to do?