• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 136
  • Last Modified:

stoppping a procedure that has been called by another upon exception

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?

0
scm0sml
Asked:
scm0sml
  • 2
1 Solution
 
S-TwilleyCommented:
So upon an error in Sub3... you want to exit out of the nested method set?
0
 
scm0smlAuthor Commented:
yeah, to avoid, after my error message has been displayed the program continuing, without ending the program, if that makes anysense
0
 
S-TwilleyCommented:
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

   ' SOME CODE

    Sub2()
    If prematureExit Then exit Sub

    ' MORE CODE
End Sub

Sub Sub2()
    Try
        'SOME BAD CODE
    Catch
        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)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now