Discussion:
limit the type of chrs in a text box
(too old to reply)
BIAF
2004-08-08 18:15:38 UTC
Permalink
1.What if i wanted only numbers to be typed into the textbox? or only
letters?


2. and how do i check if the text box has chrs like
',.,/,@,',`,¬,",£,$ etc.

i.e >> 123456$7890. How would i get vbdos to check for the $ so i
can give user a prompt to chnage it.


thx,
Derek Ross
2004-08-13 05:03:00 UTC
Permalink
Post by BIAF
1.What if i wanted only numbers to be typed into the textbox? or only
letters?
2. and how do i check if the text box has chrs like
i.e >> 123456$7890. How would i get vbdos to check for the $ so i
can give user a prompt to chnage it.
1. Here's how to do numbers only. Letters only is pretty similar

SUB Text1_KeyPress (KeyAscii AS INTEGER)

SELECT CASE KeyAscii
CASE 0 TO 31, 127, ASC("0") TO ASC("9")
CASE ELSE
LET KeyAscii = 0
END SELECT

END SUB

2. If you want to prevent these characters being entered by the user,
use the technique from (1). If you want to allow the characters to be
entered and not do the check until the user presses the OK button on
your form, make the check part of the OK button code. You can use the
INSTR( ) function to look for characters that you don't want.

Cheers

Derek

Loading...