Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Text Boxes to change Currency variable

Status
Not open for further replies.

Denk

Programmer
Jan 4, 2000
22
0
0
GB
I am using Text Boxes to make changes to a variable set as a Currency type. How do I ensure that a non numeric string cannot be entered into the Text Box?
 
Denk,<br><br>In the keypress event you can accept or reject any keystroke. It gets passed a variable called KeyAscii - you test that by saying something like<br><br>if asc(KeyAscii) = '1' etc<br><br>if you don't like the character the user types you can set the value of KeyAscii to zero to reject it.<br><br>Oh - and don't forget to allow the user to type a backspace, character number 8, I always forget this and have to go back and modify the event afterwards.<br><br><br> <p>Mike<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= Cargill's Corporate Web Site</a><br>Please don't send me email questions without posting them in Tek-Tips as well. Better yet -- Post the question in Tek-Tips and send me a note saying "Have a look at so-and-so in the thingy forum would you?" My home email is michael.j.lacey@ntlworld.com&lt
 
You could use <b>isnumeric</b><br><br>if isnumeric(text1.txt) = false then<br>&nbsp;&nbsp;&nbsp;msgbox &quot;Please enter a number&quot;<br>end if<br><br>
 
There's a FAQ entry on this now<br><br>Category &quot;<b>Processing User Input=</b>&quot;<br>Question &quot;<b>How do I make sure that only numbers are entered into a text box?</b>&quot; <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>Please -- Don't send me email questions without posting them in Tek-Tips as well. Better yet -- Post the question in Tek-Tips and send me a note saying "Have a look at so-and-so in the thingy forum would you?"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top