Using masks to restrict data entry in Textbox

I'm using VB.NET, and using the DevExpress control suite.

I have a Textbox that should accept whole number values 5 through 10 only. I'm using the DevExpress control suite, and have reviewed the Masks information at https://documentation.devexpress.com/#WindowsForms/CustomDocument583, but can't figure out how to restrict data input using those method. I've tried the various predefined masks, and tried a few custom masks, but can't restrict to those set of digits using the Mask.

So my question is: How do I restrict user input so they can enter only 5, 6, 7, 8, 9 or 10, and no other values (including decimals), using a Mask or some other property?

DevExpress allows the use of Regular Expressions for these purposes as well, but I'm not proficient enough in RegEx to know how to write a solid expression.

I realize I could do this in code in one of the Textbox events, but I have a LOT of these, and would like to explore other options.
LVL 86
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Glen RichmondCustomer Reporting Programmer.Commented:
if you only have the values of  5, 6, 7, 8, 9 or 10 and no others, why not turn it into a selection/combo/list and save user haveing to type into a textbox at all! also removes the need of getting the mask to work!
0
Robert SchuttSoftware EngineerCommented:
Untested (expired trial license...), but this RegEx should do the trick:
[5-9]|10

Open in new window

which is a slightly shorter version of
5|6|7|8|9|10

Open in new window

capture of propertiesAlso, alternatives that are more suited for number ranges I think are SpinEdit or TrackBarControl which have properties for Min/Max.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareAuthor Commented:
Thanks everyone for your suggestions. Robert's suggestion answered my question directly, so I'm awarding him points.

After discussing this with the client, however, they decided to allow decimal entry for values between 5.0 and 10. I ended up with this RegEx:

([5-9]{1}(\.\d{1})?)|([1][0])

Using this, I can enter a value between 5 and 10, including decimals. So I can enter 5 or 5.3 or 8.7 or 10, but I can't enter 10.1 (which is good).
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareAuthor Commented:
Thanks again - quick and to the point!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.