Solved

Compare string used as a sentence

Posted on 2009-05-14
5
295 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 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