Click here to Skip to main content
15,896,207 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: messagebox does not stop Pin
DaveyM6914-Jul-08 12:20
professionalDaveyM6914-Jul-08 12:20 
GeneralRe: messagebox does not stop Pin
scalpabob17-Aug-08 22:16
scalpabob17-Aug-08 22:16 
GeneralRe: messagebox does not stop Pin
DaveyM6918-Aug-08 8:11
professionalDaveyM6918-Aug-08 8:11 
Questionxml Pin
arkiboys10-Jul-08 5:03
arkiboys10-Jul-08 5:03 
AnswerRe: xml Pin
Ravi Bhavnani10-Jul-08 6:20
professionalRavi Bhavnani10-Jul-08 6:20 
QuestionRead specific cells in Excel Pin
kallileo10-Jul-08 4:47
kallileo10-Jul-08 4:47 
AnswerRe: Read specific cells in Excel Pin
led mike10-Jul-08 4:54
led mike10-Jul-08 4:54 
QuestionDetect NULL values before trying to AVG data Pin
scjsb10-Jul-08 4:15
scjsb10-Jul-08 4:15 
AnswerRe: Detect NULL values before trying to AVG data Pin
vkuttyp10-Jul-08 5:05
professionalvkuttyp10-Jul-08 5:05 
QuestionProblem Starting Windows Service Automatically Pin
karthi8410-Jul-08 3:45
karthi8410-Jul-08 3:45 
AnswerRe: Problem Starting Windows Service Automatically Pin
PIEBALDconsult10-Jul-08 4:03
mvePIEBALDconsult10-Jul-08 4:03 
GeneralRe: Problem Starting Windows Service Automatically Pin
karthi8411-Jul-08 3:06
karthi8411-Jul-08 3:06 
AnswerRe: Problem Starting Windows Service Automatically Pin
DaveyM6910-Jul-08 8:44
professionalDaveyM6910-Jul-08 8:44 
GeneralRe: Problem Starting Windows Service Automatically Pin
karthi8411-Jul-08 3:06
karthi8411-Jul-08 3:06 

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.