Get ASCII Value of KeyStroke

W

Wayne Wengert

I want to pass the ASCII value of a keystroke to a sub that checks for valid
characters (see sample below). I have looked through the possible choices
for "values" of the e.KeyChar but I can't find what I need? I am trying to
adapt an old VB6 routine so it may well be that I am going at this the wrong
way for .NET"

Any suggestions appreciated.
================= Sample Code ==============
Private Sub txtEqpVoc_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles txtEqpVoc.KeyPress

DecCheck(txtEqpVoc.Text, e.KeyChar.????)

End Sub
 
I

Imran Koradia

You can use the Asc function:

DecCheck(txtEqpVoc.Text, Asc(e.KeyChar))

hope that helps..
Imran.
 
H

Herfried K. Wagner [MVP]

Wayne Wengert said:
I want to pass the ASCII value of a keystroke to a sub
that checks for valid characters (see sample below). I have
looked through the possible choices for "values" of the
e.KeyChar but I can't find what I need?
[...]
DecCheck(txtEqpVoc.Text, e.KeyChar.????)

'AscW(e.KeyChar)', 'Asc(e.KeyChar)', 'Convert.ToInt32(c)'.
 

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