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

Exiting Subs

I have a number of sub routines all called one by one from a kind of master sub. I have an exit sub statement in the first sub (based on a value from an inputbox) - my question is: can i get the code to completely stop altogether, rather than quitting that particular sub and going to the next. I guess i could put code in the other subs to text the condition also, but there's about six of them. Suppose i'm being lazy really, but just wondered if you clever people have a quick way. Thanks.

Ps. and what happened to posting 10 point questions on this thing?
0
davsay
Asked:
davsay
1 Solution
 
Arthur_WoodCommented:
what programming language are you using?

AW
0
 
ksokolowskiCommented:
 Convert them to functions that return a boolean value on whether they finish or not..  

 Then in your main sub

just do this

 if NOT fun1(foo) Then
     exit sub
  .
  .
  .
  .
  .
  if NOT fun2(bar) Then
    exit sub

 The amount of extra effort required to do it would be minimal..
0
 
davsayAuthor Commented:
Ok, (this was in Excel VBA by the way).

I think i have it, inspired by K's answer so you can have the points. This was way easier than i first thought and really my question was probably misguided. Things seem much clearer this morning. To remedy the situation I just put a condition in the main sub (the one that calls the others). The original test condition was in the first sub (that actually did something) I incorrectly thought it would run through all the otehrs, but of course it goes back to the main sub to get its next direction. Silly me.

Thanks.  
 
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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