VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Validates keystrokes for an object's KeyPress event

E Benfield  (1 Submission)   String Manipulation   VB 6.0   Unknown Difficulty   Mon 26th April 2004   Mon 8th February 2021

Validates keystrokes for an object's KeyPress event

API Declarations


'Feel free to use this code freely. If you make enhancements, share them.
'This code does multiple things:
'1. It validates a keystroke based on the ValidChars or InvalidChars, and cancels the keystroke entirely if invalid (sets KeyAscii to 0, which is passed by reference)
'2. If KeyAscii is vbKeyReturn (ENTER key), it swaps the keystroke for a {TAB} action (tabs to the next field, great for 10-key apps)
'3. The PurgeText routine will clean up a string based on the ValidChar or InvalidChar set (necessary if the user pastes a string into a restricted field, which bypasses the check on individual keystrokes)

Global Const InvalidChar_WINFILESYSTEM = "/*?<>|""" 'series of " adds Chr$(34) to the string
Global Const InvalidChar_WINFILENAME = "/\:*?<>|""" 'series of " adds Chr$(34) to the string
Global Const ValidChar_NUMERIC = "1234567890.-"
Global Const ValidChar_NUMERICWHOLE = "1234567890-" '(no decimal)


Rate Validates keystrokes for an object's KeyPress event (2(2 Vote))
Validates keystrokes for an object's KeyPress event.bas

Validates keystrokes for an object's KeyPress event Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters