473,383 Members | 1,925 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,383 software developers and data experts.

How do I know if the value in a KeyEventArgs is printable?

How do I know if the value in a KeyEventArgs is printable?

Basicacally, in KeyUp I'd like to know if the character is printable, as
opposed to say, a backspace.

I suppose I could check KeyValue against some integers which I could get
from an ASCII table.

Isn't there a better way?

Thanks
Nov 21 '05 #1
5 3254
This is just off the top of my head, so I don't know whether it would be
useful to you.

The KeyPress event fires on printable characters. You might record the key
press argument in the form's instance data, and inspect it in the KeyUp
event (clear it in the KeyUp event after you inspect it so that it won't
linger for the next keyboard input). If the KeyPress event stored nothing
before KeyUp occurred, you can assume that the key input you're handling was
not printable.

Tom Dacon
Dacon Software Consulting

" **Developer**" <RE*************@a-znet.com> wrote in message
news:ev**************@TK2MSFTNGP12.phx.gbl...
How do I know if the value in a KeyEventArgs is printable?

Basicacally, in KeyUp I'd like to know if the character is printable, as
opposed to say, a backspace.

I suppose I could check KeyValue against some integers which I could get
from an ASCII table.

Isn't there a better way?

Thanks

Nov 21 '05 #2
Thanks, I'll try it now.
"Tom Dacon" <td****@community.nospam> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
This is just off the top of my head, so I don't know whether it would be
useful to you.

The KeyPress event fires on printable characters. You might record the key
press argument in the form's instance data, and inspect it in the KeyUp
event (clear it in the KeyUp event after you inspect it so that it won't
linger for the next keyboard input). If the KeyPress event stored nothing
before KeyUp occurred, you can assume that the key input you're handling
was
not printable.

Tom Dacon
Dacon Software Consulting

" **Developer**" <RE*************@a-znet.com> wrote in message
news:ev**************@TK2MSFTNGP12.phx.gbl...
How do I know if the value in a KeyEventArgs is printable?

Basicacally, in KeyUp I'd like to know if the character is printable, as
opposed to say, a backspace.

I suppose I could check KeyValue against some integers which I could get
from an ASCII table.

Isn't there a better way?

Thanks


Nov 21 '05 #3
Developer,

In my idea are all characters above the control range 32 (decimal)
printable.
http://www.geocities.com/Athens/Acad.../fontset.htm#b

Sometimes are different code pages used. (Can only be a problem on an old
printer in my idea)
http://www.microsoft.com/globaldev/r...ocversion.mspx

Therefore can you enlighten us more what is the problem.

Cor
Nov 21 '05 #4
" **Developer**" <RE*************@a-znet.com> schrieb:
How do I know if the value in a KeyEventArgs is printable?

Basicacally, in KeyUp I'd like to know if the character is printable, as
opposed to say, a backspace.


If you use the 'KeyPress' event instead of 'KeyUp', the character will be
passed as part of the 'e' parameter, which is of type 'KeyPressEventArgs':

\\\
If Char.IsWhiteSpace(e.KeyChar) OrElse Char.IsControl(e.KeyChar) Then
...
Else
...
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5
thanks

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:ey**************@TK2MSFTNGP12.phx.gbl...
Developer,

In my idea are all characters above the control range 32 (decimal)
printable.
http://www.geocities.com/Athens/Acad.../fontset.htm#b

Sometimes are different code pages used. (Can only be a problem on an old
printer in my idea)
http://www.microsoft.com/globaldev/r...ocversion.mspx

Therefore can you enlighten us more what is the problem.

Cor

Nov 21 '05 #6

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

Similar topics

3
by: Pascal | last post by:
Hello, What's the best way to delete or replace no-printable characters in a string. i.e.: "\x08toto\x00titi" -> "tototiti" or " toto titi"
2
by: Daniel Alexandre | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi there, I'm using the following method in my program to check whether a message received is printable or not and to strip the non-printable...
16
by: cwizard | last post by:
I'm calling on a function from within this form, and there are values set but every time it gets called I get slammed with a run time error... document.frmKitAmount.txtTotalKitValue is null or not...
1
by: Chaoxiang | last post by:
the KeyEventArgs.KeyCode is readonly, so I want to override it. How to do it? I create a class, public class ExteKeyEventArgs : KeyEventArgs { ExteKeyEventArgs(Keys keys) } but it has a...
5
by: moondaddy | last post by:
I'm going to use an aspx page to display an invoice that customers can print from. Sometimes when I go to a site and navigate to a page I want to print, they will have a button that says something...
2
by: Bryan | last post by:
Apologies if this is a noob question, but I've been struggling with this for quite a while... I'm trying to convert a byte array (encrypted authorization code) into a *screen-printable* string...
2
by: Barney | last post by:
Hi, This is my first query in google groups. I expect to donīt do it wrong, and excuse me for my english, i havenīt used it for years... Iīm making a user component that inherits from a textbox....
1
vinci
by: vinci | last post by:
Help Me!!!! T_T I want to create an instance of System.Windows.Forms.KeyEventArgs in vb.net for me to be able to use the .keyCode method of that class...is this possible??? basically, i want...
4
by: John K Masters | last post by:
>From what I have read the string module is obsolete and should not be used but I am working on a project that parses printable files created in a DOS program and creates a web page for each file....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.