Q
Problem solve Get help with specific problems with your technologies, process and projects.

How do I trap key presses in VB.NET?

How do I trap key presses in VB.NET? This used to be pretty easy in VB6 using ASCII values generated by the keys. I have a text box in which I only want the user to be able to enter digits 0-9. Thank you.
Trapping events are best performed using the TextChanged event of the textbox control. If you wish to trap the value you could at each instance of the event, check for the value of the control and if not between the range of values you mention, then to prompt an error.

Dig Deeper on Win Development Resources

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

TheServerSide.com

Close