Click here to Skip to main content
15,905,427 members
Home / Discussions / C#
   

C#

 
GeneralRe: Destroying Object from memory Pin
Scott Dorman10-Jul-08 17:02
professionalScott Dorman10-Jul-08 17:02 
AnswerRe: Destroying Object from memory Pin
N a v a n e e t h10-Jul-08 19:32
N a v a n e e t h10-Jul-08 19:32 
QuestionMouse event Pin
zeeShan anSari10-Jul-08 8:18
zeeShan anSari10-Jul-08 8:18 
AnswerRe: Mouse event Pin
DaveyM6910-Jul-08 8:29
professionalDaveyM6910-Jul-08 8:29 
QuestionRe: Mouse event Pin
zeeShan anSari10-Jul-08 8:34
zeeShan anSari10-Jul-08 8:34 
AnswerRe: Mouse event Pin
TheFM23410-Jul-08 9:48
TheFM23410-Jul-08 9:48 
AnswerRe: Mouse event Pin
PIEBALDconsult10-Jul-08 8:46
mvePIEBALDconsult10-Jul-08 8:46 
QuestionSimple Regex question Pin
kozu10-Jul-08 8:13
kozu10-Jul-08 8:13 
AnswerRe: Simple Regex question Pin
Jimmanuel10-Jul-08 8:26
Jimmanuel10-Jul-08 8:26 
AnswerRe: Simple Regex question Pin
User 665810-Jul-08 8:38
User 665810-Jul-08 8:38 
AnswerRe: Simple Regex question Pin
Daniel Grunwald10-Jul-08 8:44
Daniel Grunwald10-Jul-08 8:44 
AnswerRe: Simple Regex question Pin
jas0n2311-Apr-09 22:39
jas0n2311-Apr-09 22:39 
QuestionCreate a SQL like activity monitor Pin
Kit Fisto10-Jul-08 6:58
Kit Fisto10-Jul-08 6:58 
AnswerRe: Create a SQL like activity monitor Pin
Ashfield10-Jul-08 9:30
Ashfield10-Jul-08 9:30 
QuestionHow to read txt file and open DataBase Pin
Admin88710-Jul-08 6:10
Admin88710-Jul-08 6:10 
AnswerRe: How to read txt file and open DataBase Pin
Saksida Bojan10-Jul-08 8:38
Saksida Bojan10-Jul-08 8:38 
QuestionCan someone help me to find the equivalent Linq expressions? Pin
Michael Sync10-Jul-08 6:04
Michael Sync10-Jul-08 6:04 
AnswerRe: Can someone help me to find the equivalent Linq expressions? Pin
Michael Sync10-Jul-08 16:20
Michael Sync10-Jul-08 16:20 
Questionevents adding and removing Pin
netJP12L10-Jul-08 5:49
netJP12L10-Jul-08 5:49 
AnswerRe: events adding and removing Pin
Thomas Stockwell10-Jul-08 10:35
professionalThomas Stockwell10-Jul-08 10:35 
AnswerRe: events adding and removing Pin
PIEBALDconsult10-Jul-08 11:33
mvePIEBALDconsult10-Jul-08 11:33 
Questionmessagebox does not stop [modified] Pin
scalpabob10-Jul-08 5:47
scalpabob10-Jul-08 5:47 
Hi there,

I am writing an application to run on the compact framework.
The application accepts data from a usb barcode scanner and validate the entry against data held on a file read sequentially.
If the barcode data does not match the data on the file I want my user to be able to decide to accept the entry or not, so far so good.
I have a problem with my messagebox.show selection.
The problem is that the messagebox does not display for longer than 1/2 a second or so and code keeps running until the end of the method without stopping.
ps:The carriage return marks the end data input.

Here is the code:

// Textbox to catch the data from the USB scanner
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
try
{
if (e.KeyChar == 13) // Catch carriage return from barcode
{
string scannedData = textBox1.Text.Trim();
this.lblBarCode.Text = scannedData;
if (validate_data(scannedData) == false)
{
this.textBox1.Enabled = false;
DialogResult dlgRes = MessageBox.Show("BarCode data does not match, Accept entry ?",
"Validate BarCode",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1);


if (dlgRes == DialogResult.Yes)
{
// TODO write to output file, don't forget system date !!
}
else
{
// TODO ignore input tidy up
}
}
else
{
// TODO write to output file, don't forget system date !!
}

}
}
catch (Exception z)
{
MessageBox.Show("Error " + z);
}


}
private Boolean validate_data(string scannedData)
{
int i = 0;
string lineData;
lineData = this.lstBoxFiles.SelectedItem.ToString();
i = lineData.IndexOf("-") + 1;
lineData = lineData.Substring(i);

if (lineData != scannedData)
{
return false;
}
else
return true;
}
}


Would any one be so kind as to explain what I am doing wrong.
Thank you

modified on Friday, July 11, 2008 9:55 AM

AnswerRe: message box does not stop Pin
DaveyM6910-Jul-08 8:35
professionalDaveyM6910-Jul-08 8:35 
GeneralRe: messagebox does not stop [modified] Pin
scalpabob10-Jul-08 20:36
scalpabob10-Jul-08 20:36 
GeneralRe: messagebox does not stop [modified] Pin
scalpabob11-Jul-08 3:38
scalpabob11-Jul-08 3:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.