Force a Text Box to Accept Numeric Input Only
Category:Forms and Controls
Author:Intelligent Solutions Inc.
There are a number of controls on this site that allow you to force a text box's input to be numeric only, upper or lower case only, or so on. They are all good, but they may be more than you need. Often, all you want to do is limit a text box to numeric input (between 0 - 9). If so, you can add this one line to the text box's keypress event. If you need more sophistication (e.g., allowing for decimals, currency symbols, etc.), search the site for the above-mentioned controls.
Instructions: Copy the declarations and code below and paste directly into your VB project.