Convert String to KeyCode

M

Mr B

KC1960,

Can you elaborate a little more? A "string" can be of any length and can
contain many characters.

Please try to explain exactly what are you really wanting to do?

Mr B
askdoctoraccess dot com
 
J

John W. Vinson

Is there a way to convert a string to keycode?

For keys that correspond to ASCII characters, you can use the Asc() function:
e.g. Asc("A") is 65, and 65 is also the value of vbKeyA.

It gets harder when you try to use non-ASCII characters, or lower case
characters, or characters which could be rendered by different keys - e.g. the
numeric keypad 3 has a different keycode than the typewriter keyboard 3 :

?vbkey3
51
?vbkeynumpad3
99

You can use the Object Browser to look at the KeyCodeConstants collection if
this is something you want to deal with.
 

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

Similar Threads


Top