views:

65

answers:

1

Hello everybody,

How to a raise a keypress event for Special Character for typing extended ASCII Characters ?

Sample code snippet :

keybd_event vbKeyE, 0, KEYEVENTF_KEYDOWN, 0

Is there any alternative so that I can use KeyCode for Special character [ E.g. Chr$(122) ] instead of predefined and limited VbKeyA, VbKeyB, VbKeyC ..... etc ?

Waiting for your reply.

Regards,

Shankar

A: 

Here is an example that seems to cover your question:

Private Sub Text1_KeyPress (KeyAscii As Integer)
   If KeyAscii = 8 Then MsgBox "You pressed the BACKSPACE key."
End Sub

It was taken from here.

njak32
Hello Njak32. Thanks. But I want to type special characters from my keyboard (As i want to use a local language font for phonetic typing). Suppose if I press 'A' from the keyboard it should print Chr$(243) or Chr$(199), etc. Waiting for your reply. Regards.
Shankar
I see... that seems far more difficult if I understand correctly, as you are then required to map each key on your keyboard to its phonetic counterpart in whatever language you are using. My suggestion would be to map each key to a variable containing your desired output and perhaps save it in an array. Therefore, at each KeyPress you would output the element of the array stored at that particular ASCII code.
njak32
Thanks Njak. Could you possibly post a bit of code snippet as an example ?
Shankar
Well you would put something like this within the KeyPress event.Dim letters(256) as stringletters(97) = phonetic equivalent of aletters(98) = phonetic equivalent of b...If KeyAscii = 97 Then MsgBox letters(97)End IfOf course your array would have to contain your entire desired ASCII table, and the first element (0) would be nothing, so be careful you don't ever refer to it.
njak32
I would have thought the native Windows IME would be the best option? You wouldn't need to do anything special in your code.
MarkJ
How do I use Windows IME through VB, MarkJ ??
Shankar