Multiple Textbox Keypress

adickie

New member
Local time
Today, 15:33
Joined
Jan 28, 2003
Messages
9
I have taken advantage of posts on this board for almost a year, but this is my first post.

I have a form with about 175 text boxes that are used to enter quantities. I want to restrict all of those textboxes to 0-9, backspace and delete. I know how to do this in the keypress event for a textbox, but that would get rather long of I created a keypress event for each text box. Does anybody know how I can limit 175 textboxes with a smaller piece of code.

Thanks
 
Hi

I'd create a function

Public Function CheckInput(KeyAscii As Integer)

CheckInput = IIf((KeyAscii = vbKeyDelete Or KeyAscii = vbKeyBack Or (KeyAscii >= 48 And KeyAscii <= 57)), KeyAscii, vbKeyClear)

End Function


and then put the following line of code

KeyAscii = CheckInput(KeyAscii)

in each of the 175 text box keypress events.

HTH

shay :cool:
 

Users who are viewing this thread

Back
Top Bottom