Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Handling - Best Practice

Status
Not open for further replies.

jopaumier

Programmer
Mar 15, 2002
97
US
I have a form (FORM1) on which a user fills in some information. When the NEXT button is pressed, a bunch of activity occurs, including a call to a SUB, which in turn makes a call to another sub (both in modules). The structure is something like:

FORM1
do stuff
call SUB1
hide FORM1, show FORM2

SUB1
do some prep stuff
call SUB2

SUB2
do more stuff
do related stuff

Where are the best locations and type of error handlers(GOTO, RESUME) to the program back to FORM1, prevent it from continuing, AND inform the user of the nature of the error? I put error handlers in each sub, but I am not getting the desired results. For example, if an error occurs at "do more stuff", I want to get back to FORM1 and let the user know an error occurred at "do more stuff" and allow the user to exit or attempt a different action.

From my limited, and maybe misinformed, understanding of error handlers (as well as coming from a procedural Fortran world), if I put an error handler in SUB2, then in SUB1 and FORM1, err.num=0 and err.description=blank. Without an error handler in SUB2 and SUB1, the error bubbles up to FORM1 if there is an error handler in FORM1, which gives me part of what I want, but how do I tell the user what happened so he/she can make an informed decision?

Examples I've seen of error handling code (a few lines of code and maybe two subs) seem to be too simplistic for my situation. In my Fortran world, I'd use flags and messages as sub arguments, but is this 'good practice' in the VB world?

Thanks,
Jim
 
Check out faq222-1694.

Thanks and Good Luck!

zemp
 
Thanks, zemp. Didn't think to check the FAQs when I was doing a keyword search to see if anyone had asked the question before.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top