unhandled exception dialog box

  • Thread starter Thread starter Allen
  • Start date Start date
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
unhanled exception dialog box together wilth 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 ");
}
}
 
Answered in microsoft.public.dotnet.general.

Please never multipost (i.e posting the same message separetely to multiple
groups) and avoid crossposting (usually a single group should be
relevant)...
 
Back
Top