stoppping a procedure that has been called by another upon exception

Posted on 2005-03-25
Medium Priority
Last Modified: 2010-04-23
Say for instance I have 3 procedures sub1,sub2,sub3.

sub1 does some processing then calls sub2, which again does some processing and then calls sub3.

In sub3 an error or exception occurs such as invalid text is entered in a textbox etc.

rather than displaying an error message and then having to pass an exception all the way back to sub1 is not possible to stop 'processing' after the error message is displayed to allow the user to make the necassary changes?

something along the lines of Exit sub etc but obviously that would only stop the current procedure, im looking for something that will just return the user to the form in its current state

 any1 help?

Question by:scm0sml
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 12

Expert Comment

ID: 13629775
So upon an error in Sub3... you want to exit out of the nested method set?

Author Comment

ID: 13629806
yeah, to avoid, after my error message has been displayed the program continuing, without ending the program, if that makes anysense
LVL 12

Accepted Solution

S-Twilley earned 2000 total points
ID: 13629833
Well... im unaware of any command that will bring you out of the current nested method set... one work around i can think of is to use a boolean flag:

something like:

Dim prematureExit As Boolean = False

Sub Sub1
    prematureExit = False


    If prematureExit Then exit Sub

End Sub

Sub Sub2()
        'SOME BAD CODE
        prematureExit = True
        Exit Sub
     End Try
End Sub


one other possible one I can think of might be to start the initial sub/method in its own thread, then on an error terminate the current thread... im not sure if that'll work off the top of my head though (eating lunch at the mo, so will check after)

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question