Solved

Compare string used as a sentence

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now