473,387 Members | 1,812 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.

intercepting keys

I need to access some unicode characters from the keyboard for single
textbox on a form I've built. I've done this before using the code
below, but now I need to substitute the forward slash and period
character ("/", ".") but I can't find the named constant for these
characters in the KEYS data type. Anyone know that their name is? Or a
good workaround?

Thanks,
maxhodges
Nov 20 '05 #1
2 2607
You could try something like

Private Sub txtUser_KeyPress(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles txtUser.KeyPress
Dim KeyAscii As Integer = Asc(e.KeyChar)

If KeyAscii = 46 Then ' The period
KeyAscii = 0 'place whatever ascii value you want
End If
If KeyAscii = 92 Then ' The backslash.
KeyAscii = 0 'place whatever ascii value you want
End If

If KeyAscii = 0 Then
e.Handled = True
End If
End Sub

maxhodges wrote:
I need to access some unicode characters from the keyboard for single
textbox on a form I've built. I've done this before using the code
below, but now I need to substitute the forward slash and period
character ("/", ".") but I can't find the named constant for these
characters in the KEYS data type. Anyone know that their name is? Or a
good workaround?

Thanks,
maxhodges


Nov 20 '05 #2
Hi Max,

I believe you'll find that these are the obviously named Keys.Decimal and
Keys.Divide. ;-)

I don't think they called the '\' character Keys.IntegerDivide, though!

Unfortunately it's less useful than at first sight. Keys.Divide is the key
on the numeric keypad and Keys.Decimal is similarly on the numeric keypad but
only when NumLock is on.

In KeyDown you can use
If e.KeyCode = 191 Then .. 'Main keyboard '/'
If e.KeyCode = 111 Then .. 'Num keypad '/'
If e.KeyCode = 110 Then .. 'Num keypad '.' NumLock on
If e.KeyCode = 46 Then .. 'Num keypad '.' NumLock off

But only if you're using <my> keyboard or those configured the same way!

In KeyPress you can use
If e.KeyChar = "/" Then ..
If e.KeyChar = "." Then ..

Regards,
Fergus
Nov 20 '05 #3

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

Similar topics

1
by: Fabian | last post by:
I have a script that intercepts the arrow keys. I also have a dropdown menu using SELECT tags. However, when the dropdown menu has the focus, I do not want the script to intercept the keyboard. How...
6
by: Valery Polyakov | last post by:
I am drawing lines with a semi-transparent color (alpha=100). When these lines intercept, the color becomes more intense. Is there a way to avoid this, so that I would get the same intensity of...
7
by: John | last post by:
Hi, Can anyone point me out how to intercept the keystrokes from a c# application that's not a active window? - intercepting the system wide keystrokes before it hits the target active window? ...
0
by: VMI | last post by:
My Windows datagrid has two columns: one with the data that the user will see (col_X) and the other one (a hidden one: col_sort) that'll be used to sort data. When a user clicks on col_X's column...
6
by: Steve Murphy | last post by:
I have a default button on a form, but when a certain textbox has focus, I want to intercept Enter key events and perform a different action. Is there an easy way to do this, or should I just check...
10
by: Steve McLellan | last post by:
Hi, Does anyone know if it's possible (and if so, how) to intercept presses on 'multimedia keys' you find on keyboards? Curiosity more than anything. Only manufacturers seem to put their own...
4
by: Oenone | last post by:
I'm using a TabControl to facilitate a wizard-style form, using some of the techniques described here: http://www.codeproject.com/cs/miscctrl/WizardTab.asp For the most part I have this...
2
by: bryan rasmussen | last post by:
Hi, I've been looking at autohotkey to do some different usability hacks for windows http://www.autohotkey.com/ one of the benefits of this language is it allows one to catch keyboard usage,...
0
by: Gabriel Genellina | last post by:
En Thu, 18 Sep 2008 19:24:26 -0300, Robert Dailey <rcdailey@gmail.com> escribió: Why don't you try it yourself? You may replace builtins.print with your own function too. It's not exactly the...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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.