473,785 Members | 2,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IF/Then "printable character" KeyPress

How can I say "If e is equal to a printable character (as opposed to Insert,
Del, Home, PageUp, PageDown, etc) then x=1"?

Something like...

if (e.KeyChar==Pri ntableCharacter s)
{
x=1;
}
Nov 16 '05 #1
6 4165
if (e.KeyChar=='Q' )
"Keith Smith" wrote:
How can I say "If e is equal to a printable character (as opposed to Insert,
Del, Home, PageUp, PageDown, etc) then x=1"?

Something like...

if (e.KeyChar==Pri ntableCharacter s)
{
x=1;
}

Nov 16 '05 #2
"Brian Keating" <csharp at briankeating.ne t> wrote in message
news:E6******** *************** ***********@mic rosoft.com...
if (e.KeyChar=='Q' )


Is this the only way?

if (e.KeyChar=='A' or e.KeyChar=='a'; e.KeyChar=='B'; e.KeyChar=='b';
.....etc

If so then what a pain!
Nov 16 '05 #3
Keith,

Check out the static Char.IsControl method.

Regards,
Joakim

Keith Smith wrote:
How can I say "If e is equal to a printable character (as opposed to Insert,
Del, Home, PageUp, PageDown, etc) then x=1"?

Something like...

if (e.KeyChar==Pri ntableCharacter s)
{
x=1;
}

Nov 16 '05 #4
Assuming that's what you needed to do, it'd be far simpler to write:
if((e.KeyChar >= 'A' && e.KeyChar <= 'Z')) || (e.KeyChar >= 'a' && e.KeyChar
<= 'z') ...)

But I think using if(!e.KeyChar.I sControl()) as suggested by Joakim would
probably fit your needs.

"Keith Smith" <ke*********@ve rizon.net> wrote in message
news:uclPd.2563 1$Dc.13614@trnd dc06...
"Brian Keating" <csharp at briankeating.ne t> wrote in message
news:E6******** *************** ***********@mic rosoft.com...
if (e.KeyChar=='Q' )


Is this the only way?

if (e.KeyChar=='A' or e.KeyChar=='a'; e.KeyChar=='B'; e.KeyChar=='b';
....etc

If so then what a pain!

Nov 16 '05 #5
great idea thanks.
"Sean Hederman" <us***@blogentr y.com> wrote in message
news:cu******** **@ctb-nnrp2.saix.net. ..
Assuming that's what you needed to do, it'd be far simpler to write:
if((e.KeyChar >= 'A' && e.KeyChar <= 'Z')) || (e.KeyChar >= 'a' &&
e.KeyChar <= 'z') ...)

But I think using if(!e.KeyChar.I sControl()) as suggested by Joakim would
probably fit your needs.

"Keith Smith" <ke*********@ve rizon.net> wrote in message
news:uclPd.2563 1$Dc.13614@trnd dc06...
"Brian Keating" <csharp at briankeating.ne t> wrote in message
news:E6******** *************** ***********@mic rosoft.com...
if (e.KeyChar=='Q' )


Is this the only way?

if (e.KeyChar=='A' or e.KeyChar=='a'; e.KeyChar=='B'; e.KeyChar=='b';
....etc

If so then what a pain!


Nov 16 '05 #6
> How can I say "If e is equal to a printable character (as opposed to
Insert, Del, Home, PageUp, PageDown, etc) then x=1"?

Something like...

if (e.KeyChar==Pri ntableCharacter s)
{
x=1;
}


You could get the ascii-code for the char, and then check if it's within at
printable range ?

/René
Nov 16 '05 #7

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

Similar topics

0
4888
by: farseer | last post by:
Hi, i have a file which contains data that is delimted by non-printable character "0x1f". how can i parse this file with that character as the delimiter?
38
5739
by: Haines Brown | last post by:
I'm having trouble finding the character entity for the French abbreviation for "number" (capital N followed by a small supercript o, period). My references are not listing it. Where would I find an answer to this question (don't find it in the W3C_char_entities document). -- Haines Brown brownh@hartford-hwp.com
8
1921
by: Javier | last post by:
Hello: I have a problem with encoding. I get information from a web page, and sometimes it contains "strange" symbols like "á" and "é", and these come encoding like "& a a c u t e ;", "& e a c u t e ;" and similar. The problem is that i use this information in XMLDocument object, I load the string than contains all the information in this object with the method ..LoadXML(string) and this raises an exception, i think it's because it has a...
6
1809
by: Lucvdv | last post by:
In a sorted list, certain characters are grouped together, for example "çb" (cedille b) comes after "ca" but before "cc". Is there a built-in way to find out what 'base character', such as C for cedille, a character belongs to for a given globalization setting?
2
3793
by: Kannan | last post by:
In section 7.19.6.1 on ISO C specification, it says about a format character "space". When and how we will use this "space" format? I mean is there a usage, for e.g. like printf("%space",...); ? Thanks, Kannan
2
5583
by: Diilb | last post by:
I am using DOM to create an rss feed. The problem I am running into is "special characters" such as é è ç. If I try adding them to the XML as character data (CData), DOM chokes and throws out errors. If I do a search and replace on the characters changing them to HTML entities instead of using CDATA, DOM chokes up again. If I do a combination of both (search and replace then add as Character Data) it does not choke, but the RSS...
4
1376
by: Claudia Fong | last post by:
Hi, I have a windows application and I want to simulate the send email function. Is it possible? How? Ca someone tell me? Cheers!
12
2206
by: Ed | last post by:
Hi All, The sample code below doesn't work, but if you take out the Question Mark character, "?" in front of the value "Print" of the "action" attribute, it does work! Does anyone here know an other workaround? Thanks in advance! ////////////////////////////////////////////////////////////Sample
5
1723
by: rellaboyina | last post by:
Dear All, I am facing a problem in escaping the character "#" from the url. I am working in Mason framework now which uses Perl, HTML and Javascript. What I really want is to escape the character "#" from the value assigned to a variable. As this value gets appended to the url, I am not getting the correct and expected values. Eg: Suppose $value = "My#Group"; Here I want to escape the character # so that the variable $value contains...
0
9485
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,...
0
10356
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10161
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9958
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7506
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
5390
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
4058
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
3662
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2890
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.