KeyAscii code info please 
Author Message
 KeyAscii code info please

Hello all

Can some kind soul please tell me the KeyAscii code (number) for the 4 arrow
keys under the delete end & page down keys. I would like to use them in a
KeyPress sub.

Many thanks

Steve Pearson



Fri, 18 Mar 2005 04:29:22 GMT  
 KeyAscii code info please

Quote:

>Hello all

>Can some kind soul please tell me the KeyAscii code (number) for the 4 arrow
>keys under the delete end & page down keys. I would like to use them in a
>KeyPress sub.

They aren't ASCII keys, don't have ASCII values, and can't be trapped in the
KeyPress event.  You have to use KeyDown or KeyUp, and compare the available
KeyCode to vbKeyUp, vbKeyDown, vbKeyLeft or vbKeyRight, IIRC.

Lee Weiner



Fri, 18 Mar 2005 04:52:08 GMT  
 KeyAscii code info please
Hi Lee

Thanks for the reply, I must admit to being new to VB. I was looking through
the msdn information and found that let say key a is = to 97 and key A is =
to65 and so on.

So I was after the value for the four keys.

But like you say maybe there isn't one.

Cheers

Steve Pearson



Fri, 18 Mar 2005 06:03:01 GMT  
 KeyAscii code info please
Steve
Use a named literal for the key code.
try this
1 form

this code

Private Sub Form_KeyDown(KeyCode As Integer, _
Shift As Integer)
Select Case KeyCode
Case vbKeyLeft
MsgBox "You have clicked the LEFT arrow."
Case vbKeyRight
MsgBox "You have clicked the RIGHT arrow."
Case vbKeyUp
MsgBox "You have clicked the UP arrow."
Case vbKeyDown
MsgBox "You have clicked the DOWN arrow."
End Select
End Sub

HTH
George


Quote:

> Hello all

> Can some kind soul please tell me the KeyAscii code (number) for the 4
arrow
> keys under the delete end & page down keys. I would like to use them in a
> KeyPress sub.

> Many thanks

> Steve Pearson



Fri, 18 Mar 2005 06:42:09 GMT  
 KeyAscii code info please
Hi Steve,

Lee did not say "maybe there isn't one", he said "there isn't one."  If you go
back to MSDN and read the section on the VB KeyPress event from beginning to
end, you should understand.

Best regards,

John............

Quote:

> Hi Lee

> Thanks for the reply, I must admit to being new to VB. I was looking through
> the msdn information and found that let say key a is = to 97 and key A is =
> to65 and so on.

> So I was after the value for the four keys.

> But like you say maybe there isn't one.

> Cheers

> Steve Pearson



Fri, 18 Mar 2005 09:56:50 GMT  
 KeyAscii code info please

Hi George

Thanks for that, that works very well.

The way I was trying to do it was similar, But harder. My way I had to find the
number for each key on the keyboard. But using the vbKey command has to be the
way for me.

To find the number value for each key I used this code.

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

Label1.Caption = KeyCode

End sub

This gave me the number for each key, for example vbKeyUp  =  38, vbKeyDown  =
40

So using your code
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

Select Case KeyCode

Case 37 'vbKeyLeft
MsgBox "You have clicked the LEFT arrow."
Case 39 'vbKeyRight
MsgBox "You have clicked the RIGHT arrow."
Case 38 'vbKeyUp
MsgBox "You have clicked the UP arrow."
Case 40 'vbKeyDown
MsgBox "You have clicked the DOWN arrow."

End Select

End Sub

Many thanks to all, any comments always welcome

Steve Pearson

Quote:
>Steve
>Use a named literal for the key code.
>try this
>1 form

>this code

>Private Sub Form_KeyDown(KeyCode As Integer, _
>Shift As Integer)
>Select Case KeyCode
>Case vbKeyLeft
>MsgBox "You have clicked the LEFT arrow."
>Case vbKeyRight
>MsgBox "You have clicked the RIGHT arrow."
>Case vbKeyUp
>MsgBox "You have clicked the UP arrow."
>Case vbKeyDown
>MsgBox "You have clicked the DOWN arrow."
>End Select
>End Sub

>HTH
>George



>> Hello all

>> Can some kind soul please tell me the KeyAscii code (number) for the 4
>arrow
>> keys under the delete end & page down keys. I would like to use them in a
>> KeyPress sub.

>> Many thanks

>> Steve Pearson



Fri, 18 Mar 2005 21:54:09 GMT  
 KeyAscii code info please
You may have misinterpreted George's post. When he wrote (using one Case
statement for example purposes)

     Case vbKeyLeft
        MsgBox "You have clicked the LEFT arrow."

he didn't mean for you to change that to

     Case 37 ' vbKeyLeft
        MsgBox "You have clicked the LEFT arrow."

They perform **identically**. The vbKeyLeft is a predefined constant and
it's value is 37. You use it just as you would use any number. When you
use 37, you have to provide a comment to explain what that value stands
for. When you use vbKeyLeft, it's value is the same 37 (try Print
vbKeyLeft in the Immediate window) and it is self commenting. To see the
rest of the predefined KeyCode constants, go into the VB Help files and
type "Keycode constants" (without the quote marks).

Rick


Quote:

> Hi George

> Thanks for that, that works very well.

> The way I was trying to do it was similar, But harder. My way I had to
find the
> number for each key on the keyboard. But using the vbKey command has
to be the
> way for me.

> To find the number value for each key I used this code.

> Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

> Label1.Caption = KeyCode

> End sub

> This gave me the number for each key, for example vbKeyUp  =  38,
vbKeyDown  =
> 40

> So using your code
> Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

> Select Case KeyCode

> Case 37 'vbKeyLeft
> MsgBox "You have clicked the LEFT arrow."
> Case 39 'vbKeyRight
> MsgBox "You have clicked the RIGHT arrow."
> Case 38 'vbKeyUp
> MsgBox "You have clicked the UP arrow."
> Case 40 'vbKeyDown
> MsgBox "You have clicked the DOWN arrow."

> End Select

> End Sub

> Many thanks to all, any comments always welcome

> Steve Pearson

> >Steve
> >Use a named literal for the key code.
> >try this
> >1 form

> >this code

> >Private Sub Form_KeyDown(KeyCode As Integer, _
> >Shift As Integer)
> >Select Case KeyCode
> >Case vbKeyLeft
> >MsgBox "You have clicked the LEFT arrow."
> >Case vbKeyRight
> >MsgBox "You have clicked the RIGHT arrow."
> >Case vbKeyUp
> >MsgBox "You have clicked the UP arrow."
> >Case vbKeyDown
> >MsgBox "You have clicked the DOWN arrow."
> >End Select
> >End Sub

> >HTH
> >George



> >> Hello all

> >> Can some kind soul please tell me the KeyAscii code (number) for
the 4
> >arrow
> >> keys under the delete end & page down keys. I would like to use
them in a
> >> KeyPress sub.

> >> Many thanks

> >> Steve Pearson



Sat, 19 Mar 2005 00:18:47 GMT  
 KeyAscii code info please
You can easily grab the var yourself by adding a line such as this in the
KeyPress sub:

MsgBox KeyAscii

Just hit the arrow key and jot down the result...

Paul


Quote:

> Hello all

> Can some kind soul please tell me the KeyAscii code (number) for the 4
arrow
> keys under the delete end & page down keys. I would like to use them in a
> KeyPress sub.

> Many thanks

> Steve Pearson



Sat, 19 Mar 2005 04:42:02 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Bar CODE VBX or Info, CODE, I/O info for VB 3.0

2. Keyascii code

3. Need KeyAscii codes

4. Help w/ KeyAscii key codes

5. Help: Keyascii codes for the Arrow keys???

6. Need Bar Code Info Please!

7. Need Bar Code Info Please!

8. Need Bar Code Info Please!

9. Need Bar Code Info Please!

10. Need Bar Code Info Please!

11. Need Bar Code Info Please!

12. Can anyone HELP me PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE

 

 
Powered by phpBB® Forum Software