473,387 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Getting Keystroke Value

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?

--
------------------------------------
Wayne Wengert
wa***@wengert.org
Jul 19 '05 #1
2 3209
Hello,

Please have a look at
http://msdn.microsoft.com/library/en...l/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,
--
Parker Zhang
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 19 '05 #2
I finally found what I needed

Dim keycode As Integer
Dim chrInput As Char

chrInput = "A"
keycode = AscW(chrInput)

keycode = 65

Wayne

"Wayne Wengert" <wa***@wengert.org> wrote in message
news:uI**************@tk2msftngp13.phx.gbl...
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?

--
------------------------------------
Wayne Wengert
wa***@wengert.org

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ste | last post by:
Hello, my goal would be implementing some keystroke analysis using php. I'm a novice in php, so i ask your advice: according to you, is it possible to log each keystroke client-side even if php is...
7
by: hokieghal99 | last post by:
Does anyone know of a keystroke logger that has been written in Python for Windows machines? I'd like to see such a script and use it as a point of reference for a real-time backup project that I'm...
1
by: Amin Gunawan via .NET 247 | last post by:
I would like to put a combo box in a column of a datagrid. I've seen the samples in the MSDN library of other sources, butall samples didn't catch the 'DOWN/UP' keystroke. It means thatwhen I select...
15
by: Frank Bormann | last post by:
Hi, probably a stupid question, but I haven't been able to find anything. Is there a istream related function that let me read exactly one keystroke from the keyboard through cin? What I...
4
by: Andrew DeFaria | last post by:
I'm trying to use the onKeyDown event on a text field. I intersept the keystroke, interpret it and then do certain actions based on certain keys stuck. If a special key is stuck I replace the value...
3
by: Wayne Wengert | last post by:
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...
2
by: Wayne Wengert | last post by:
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 =...
2
by: beaker | last post by:
Hello, I'm writing a program (which will be running in the background 99% of the time) and I want to be able to work out how long it has been since the user last used the mouse and/or keyboard. ...
3
Claus Mygind
by: Claus Mygind | last post by:
with the "onKeyPress" event handler I see that I can capture and examine the value of a keystroke before it is displayed on the screen. I have made good use of this for single character fields where...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.