does anyone knows how the code to allow only percentage format to be input at textbox? (3 digits or less , 1 decimal point, 2 digits). i would also want to limit to 100.00
Anytime I want to validate something I highly consider regular expressions. If you are not familiar with them, they seem a little confusing at first, but once you get the hang of them it pays off. They are very fast and very streamline. A great site to get you started on Regular Expressions is: http://www.regexlib.com/
I have created the RegEx you were asking for, see below. It forces the user to have at a minimum a decimal point and two numeric i.e. ".00". It also forces the user to stay below 100.00. I think this is exactly what you were asking for, if it isn't you can tweak the regular expression. If you need help just shoot me a PM.
'Imports
Imports System.Text.RegularExpressions
Dim RegExpression As Regex
RegExpression = New Regex("^((100.00)|([1-9][0-9]|[1-9]|)(\.\d\d))$")
If RegExpression.IsMatch(YOUR_TEXT_TO_BE_CHECKED) Then MsgBox("It's a match!") Else MsgBox("Not a match!")
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.