unhandled exception dialog box



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

Thanks a lot.

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


if (empNumBox->Text == "")

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


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

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

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

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