Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Hatsukaichi, Hiroshima, Japan
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exit Parent Sub? (vba for CorelDraw 12)

    Hello,

    My knowledge of using vba is quite limited. is there any single command to put in a secondary sub to exit out of a parent sub? I know how to pass a glbal variable back to a parent sub, get it to check the variable and the exit but I just wondered if there was a simple command to avoid using global variables. I hope the terminology I've used makes sense.

    Thanks,

    Chris (Hunt)

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Exit Parent Sub? (vba for CorelDraw 12)

    Should all execution stop? I think there is a command to halt immediately and not even return to the parent routine, but I can't recall what it is.

    Also, it might be easier to make your secondary sub into a Function if you want to return a value (and it is never run on its own, e.g., from a Macros dialog).

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Exit Parent Sub? (vba for CorelDraw 12)

    I think the instruction that Jefferson couldn't remember is End but I wouldn't recommend using it. End abruptly halts all code execution, clears all static and module level variable, destroys all objects. I'd go woth his suggestion to change the secondary sub to a function that returns a value (for example True or False) that the parent sub can inspect to decide if Exit Sub should be executed.

  4. #4
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Hatsukaichi, Hiroshima, Japan
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Exit Parent Sub? (vba for CorelDraw 12)

    Thanks, Hans and Jefferson, I have indeed settled for using a private sub and using a boolean to check for exit sub. It's good to know about End - I didn't realise it was so destructive, something to watch out for.

    All the best,

    Chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •