Getting Keystroke Value

  • Thread starter Thread starter Wayne Wengert
  • Start date Start date
W

Wayne Wengert

I want to get the decimal (integer) value of user keystrokes. I am using the
following code. chrInput is the character entered (e.g. "M") and "keystroke
is DIMed as Short

keystroke = Microsoft.VisualBasic.Val(chrInput)

but it always yields a value of 0

How should I be doing this?
 
Hello,

Please have a look at
http://msdn.microsoft.com/library/en-us/vblr7/html/vafctVal.asp.

Public Overloads Function Val(ByVal Expression As String) As Double
-or-

Public Overloads Function Val(ByVal Expression As Object) As Double
-or-

Public Overloads Function Val(ByVal Expression As Char) As Integer

If the Expression doesn't contains decimal or cannot be converted to
decimal, the return value is 0.

The following code works fine.

Dim keystroke As Short
Dim chrInput As Char
chrInput = "2"
keystroke = Microsoft.VisualBasic.Val(chrInput)
MsgBox(keystroke)

HTH,
 
I finally found what I needed

Dim keycode As Integer
Dim chrInput As Char

chrInput = "A"
keycode = AscW(chrInput)

keycode = 65

Wayne
 

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

Back
Top