Key Down Event Question

G

Guest

Hello,

If I have a Text Box & if I want that everytime someone types in a space
then to not put a Space in to just move the cursor one position to the right.
I am able to do this with VBA coding with the following:

Private Sub txtHourlyRate_KeyDown(KeyCode As Integer, Shift As Integer)

'*** If Space is hit doesnt put space just uses Right Arrow & moves right 1
If KeyCode = 32 Then KeyCode = 39

End Sub

But for the Form I am building I will have a lot of Text Boxes that I want
to do the same for. What I am looking for is help on how I can save time
instead of typing in all these KeyDown Events for each control. I know VBA
doesnt have control arrarys, so another Idea I thought of was in the
Properites, in the KeyDown Event to put a Function in, & then in the Function
change the Space to the Right Arrow.
But for the Proporties function how can I pass the "KeyCode" number so I
know what is being typed ? Can this even be done ? I hope I didnt confuse
anyone.

Any help would be greatly appreciated.

Thank you,
Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top