473,750 Members | 2,265 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Visua lBasic.Val(chrI nput)

but it always yields a value of 0

How should I be doing this?

--
------------------------------------
Wayne Wengert
wa***@wengert.o rg
Jul 19 '05 #1
2 3246
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.Visua lBasic.Val(chrI nput)
MsgBox(keystrok e)

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******** ******@tk2msftn gp13.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.Visua lBasic.Val(chrI nput)

but it always yields a value of 0

How should I be doing this?

--
------------------------------------
Wayne Wengert
wa***@wengert.o rg

Jul 19 '05 #3

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

Similar topics

3
2712
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 a server-side language, or shall i use JavaScript and make the client run the program locally? And, if i can use php to do that, how can i implement a feature logging keystrokes on the client system? Thanks,
7
6224
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 working on. Basically, I'd like to be able to capture all keystrokes from the keyboard buffer and write them to a text file so I could reporduce emails, documents, etc. in the event of file loss that occurs between nightly backups. For example,...
1
1919
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 an item in the combo box, I need to use my mousefor the selection. If I use the 'DOWN/UP' keystroke, the cell inthe grid move to the next or prev row in the grid. Anybody knows how to catch the down/up keystroke when selectingitems in the combo...
15
5757
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 need it to do is this: - remove all characters currently in the input buffer - block until the user presses a key
4
2032
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 in the text field and return false. This seems to say "get rid of the key struck - I handled it instead" for IE but not for Netscape. I set up a page, http://defaria.com/test.html to demonstrate this. If you type any character it is simply...
3
7608
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 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...
2
411
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 = Microsoft.VisualBasic.Val(chrInput) but it always yields a value of 0 How should I be doing this?
2
2796
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. I plan on using a Timer to do the checking periodically, but I'm not sure how to get the time of the last mouse click or keystroke. Any suggestions? I've seen examples on keyboard loggers but they seem to focus on capturing all keystrokes,...
3
1753
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 I want to examine if the value is correct and also convert the value to upper case like so: <input type="text" name="f1" id ="f1" maxLength="1" onKeyPress="return isHorS(event);" />
0
9000
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8838
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9339
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6804
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4713
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3322
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2804
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2225
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.