Exiting Subs

Posted on 2003-02-28
Medium Priority
Last Modified: 2010-04-17
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?
Question by:davsay
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
LVL 44

Expert Comment

ID: 8046351
what programming language are you using?


Accepted Solution

ksokolowski earned 80 total points
ID: 8046451
 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..

Author Comment

ID: 8047797
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.


Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Introduction to Processes

765 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