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.
Expand|Select|Wrap|Line Numbers
- 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 ");
- }
- }
Thanks
Allen