Getting ASCII code on KeyPress event 
Author Message
 Getting ASCII code on KeyPress event

I want to prevent characters other than the following from being entered into
a text box:

0 to 9
A to Z (upper case only)
. (full stop)
- (minus sign)

I have tried using the KeyPress event and setting KeyCode to null but there
is no KeyCode for . or -. Also it dose not differentiate between upper
case and lower case.

Can I retrieve the ASCII value of the character entered within the KeyPress
event procedure?

Cheers,
Seth



Tue, 22 Jan 2008 09:56:02 GMT  
 Getting ASCII code on KeyPress event

Quote:
> I want to prevent characters other than the following from being
> entered into a text box:

> '0' to '9'
> 'A' to 'Z' (upper case only)
> '.' (full stop)
> '-' (minus sign)

> I have tried using the KeyPress event and setting KeyCode to null but
> there is no KeyCode for '.' or '-'. Also it dose not differentiate
> between upper case and lower case.

> Can I retrieve the ASCII value of the character entered within the
> KeyPress event procedure?

Are you sure you've been looking at the KeyPress event and not the
KeyDown event?  The KeyPress event procedure receives an argument,
KeyAscii As Integer, which is the ASCII value of the key that was
pressed.  Note that non-ASCII keys will fire KeyDown and not KeyPress.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)



Tue, 22 Jan 2008 10:02:46 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. KeyPress Event and Appropriate Codes?

2. Creating Custom Event Handler (KeyPress Event)

3. Assigning event to Shift-Tab in KeyPress event

4. Importing ASCII file with ASCII CHar Code #28 as delimiter

5. In vbs exist the keypress event

6. Keypress event

7. Where is the keypress event while editing a cell

8. How do Key Codes compare to ASCII codes?

9. How can I catch a keypress-event?

10. catch the keypress-event to delete records


 
Powered by phpBB® Forum Software © phpBB Group