unhandled exception

A

Allen

I use V C++ 2008. From the code below I am trying to make a program that
will ask the user to enter a number into the text box. If the user click
"Enter", without entering a number a dialog box will come up to show that
unhandled exception has occurred..

I want to prevent the unhandled.. dialog box from coming up. I want to use
a message box instead, to promt the user to enter a number and the program
should go on.

I noticed that if I iliminte all codes after the end of the catch block,
only my message box will show up, but the unhandled exption dialog box
would not show up. If I leave the mentioned codes in place, then the
unhandled exception dialog box together with my message box will show up.
Can anybody tells me why that is happening and what should I do to fix this
problem.

Thanks a lot.


private: System::Void BtnIn_Click(System::Object^ sender,
System::EventArgs^ e)
{

try

{
empNumBox->Text;
if (empNumBox->Text == "")

throw gcnew System::ArgumentException(L" You have to enter your employee
code");

}

catch(System::ArgumentException^ pex)
{
MessageBox::Show(pex->Message,L" Error ");
}


Int32 temp = Convert::ToInt32(empNumBox->Text);
switch (temp)
{
case 1:
{
Do something
}
break;

default: MessageBox::Show(" This is an invalid employee number.\n Please try
again! ",L" Error ");
}
}
 
G

Guest

I use V C++ 2008.  From the code below I am trying to make a program that
will ask the user to enter a number into the text box.  If the user click
"Enter", without entering a number a dialog box will come up to show that
unhandled exception has occurred..

I want to prevent the unhandled.. dialog box from coming up.  I want to use
a message box instead, to promt the user to enter a number and the program
should go on.

I noticed that if I iliminte all codes after the end of the catch block,
only my message box  will show up, but the unhandled exption dialog box
would not show up.  If I leave the mentioned codes in place, then the
unhandled exception dialog box together with my message box will show up.
Can anybody tells me why that is happening and what should I do to fix this
problem.

Thanks a lot.

private: System::Void BtnIn_Click(System::Object^  sender,
System::EventArgs^  e)
{

 try

 {
 empNumBox->Text;
 if (empNumBox->Text == "")

 throw gcnew System::ArgumentException(L" You have to enter your employee
code");

}

 catch(System::ArgumentException^ pex)
 {
 MessageBox::Show(pex->Message,L" Error ");

}

Int32 temp = Convert::ToInt32(empNumBox->Text);
switch (temp)
{
case  1:
{
Do something}

break;

default: MessageBox::Show(" This is an invalid employee number.\n Please try
again! ",L" Error ");

}
}

Hi Allen, you posted in the asp.net group, please use
microsoft.public.dotnet.languages.vc instead
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top