Solved

Compare string used as a sentence

Posted on 2009-05-14
5
297 Views
Last Modified: 2012-05-07
The following Code will not except a string with spaces in them, Also it will not work if the first letter is a sash "\" example

\OFFICE 67
\DIRECT

I'm scanning this data into a scanner program I developed using C# it blowes up when it hit a space or a "/"


if (!Char.IsLetterOrDigit(e.KeyChar) && e.KeyChar != '\b')
{
 
 
}

Open in new window

0
Comment
Question by:daruffin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
AndreSteffens earned 125 total points
ID: 24386440
Hi,
What exception message do you get?
Where is the 'e'  variable coming from?
0
 

Author Comment

by:daruffin
ID: 24387871
I'm developing in Windows CE

private void txtbox_KeyPress_Number(object sender, KeyPressEventArgs e)
0
 
LVL 4

Expert Comment

by:AndreSteffens
ID: 24388183
When I call the method below with ReadChar(new KeyPressEventArgs('/') I get no exception.
So are you sure your code "blows" up where you think it does?
What exception message do you get?
 public void ReadChar(KeyPressEventArgs e)
        {
            if (!Char.IsLetterOrDigit(e.KeyChar) && e.KeyChar != '\b')
            {
                
 
            }
 
        }

Open in new window

0
 

Author Comment

by:daruffin
ID: 24389748
I will review it and get back to you tomorrow.
0
 

Author Comment

by:daruffin
ID: 24423471
Sorry for the delay I have been on Vacation.

The problem is when I scan /INSTALL the first char is changed to ")" meaning when it finishes I have something like this

)NSTALL

 it takes the I out and changes the "/" to this ")"

Also it does not work for *INSTALL when I scan it.

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question