Wrox Programmer Forums
|
BOOK: Ivor Horton's Beginning Visual C++ 2008 ISBN: 978-0-470-22590-5
This is the forum to discuss the Wrox book Ivor Horton's Beginning Visual C++ 2008 by Ivor Horton; ISBN: 9780470225905
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Visual C++ 2008 ISBN: 978-0-470-22590-5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 6th, 2009, 11:36 PM
Registered User
 
Join Date: Oct 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default unhandled exception and Forms

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 “OK”, 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.
Code:
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
 
Old December 7th, 2009, 02:57 AM
Friend of Wrox
 
Join Date: Nov 2009
Posts: 156
Thanks: 13
Thanked 16 Times in 16 Posts
Default

what is effect of following line in your program?
empNumBox->Text;
 
Old December 8th, 2009, 05:21 PM
Registered User
 
Join Date: Oct 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think, if I remove it there will be no change.





Similar Threads
Thread Thread Starter Forum Replies Last Post
unhandled exception dipakp ASP.NET 2.0 Professional 1 July 6th, 2007 02:16 PM
Unhandled NullReference Exception dheeraj1053 C# 1 May 30th, 2006 05:55 PM
Unhandled NullReference Exception MAKO C# 1 April 19th, 2006 05:46 AM
Unhandled Exception stu9820 ASP.NET 1.0 and 1.1 Basics 11 January 14th, 2004 05:55 PM
Unhandled Exception: mbarrett C# 3 August 1st, 2003 05:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.