Editing Input

G

Guest

I am trying to edit a value the user is placing in a text box on the form.
The value needs to be unbound, numeric, 1 character long between 0 and 5
inclusive. When I use the KeyDown event, I can edit if the user presses the
number above the letters, but if the user presses from the numeric keypad, it
doesn't work. Those values are interpreted as if they are alpha characters.

I've tried the lost focus event, but that never fires.

Any suggestions.
Thanks
 
J

John Griffiths

Alternative.

Change text box to combo box.

Set Row Source Type to "Value List"
Set the RowSource to "0;1;2;3;4;5"
Set Limit To List to "Yes"

If the numbers relate to something other than scalar quantities you can
describe each value..
ie
Set the RowSource to "0;None;1;Mr;2;Mrs;3;Miss;4;Ms;5;Your Majesty"
Set Column Count to "2"
Set Column Widths to "0.501cm;2cm"
Set List Width to "2.54cm"

Regards John
 
G

Guest

John Griffiths said:
Alternative.

Change text box to combo box.

Set Row Source Type to "Value List"
Set the RowSource to "0;1;2;3;4;5"
Set Limit To List to "Yes"

If the numbers relate to something other than scalar quantities you can
describe each value..
ie
Set the RowSource to "0;None;1;Mr;2;Mrs;3;Miss;4;Ms;5;Your Majesty"
Set Column Count to "2"
Set Column Widths to "0.501cm;2cm"
Set List Width to "2.54cm"

Regards John




I guess I should have been more explicit. I tried to simplify the problem, but alas, I simplified it too much. The value in the text box can be any numeric value, including a decimal value. The user must be able to enter this value using the numeric key pad or the row of numbers above the alpha characters.

Thanks
 
J

John Griffiths

Oranges and Apples

KeyDown is more for specific keys on keyboard (hardware oriented)
KeyDown(KeyCode, Shift)
KeyCode = vbKeyNumpad1 = 97 (&H61)
Chr(97) will return "a"

KeyPress is more for getting values (software oriented)
KeyPress(KeyAscii)
KeyAscii = 49
Chr(49) will return "1"

Regards John

problem, but alas, I simplified it too much. The value in the text box can
be any numeric value, including a decimal value. The user must be able to
enter this value using the numeric key pad or the row of numbers above the
alpha characters.
 

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