Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Call out specfic part of routine (A2002)

    Hello All,
    I have a quick question. How do you call a specific part of a routine from another routine? I use this type of thing all the time where I call another routine, but I need to go to a specific part of another routine. I do have a tag with (":") inside the routine where I want to go.

    Thanks,
    Mark

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

    Re: Call out specfic part of routine (A2002)

    You cannot jump to a label in another procedure. Perhaps it is possible to move the section of code you want to call into a separate procedure or function, and call this from both routines. You could also add an optional argument to the procedure. Let's say the present definition is

    Sub MyProc(MyArg As Long)
    ...
    MyLabel:
    ...
    End Sub

    Change this to

    Sub MyProc(MyArg As Long, Optional Jump As Boolean = False)
    If Jump = True Then GoTo MyLabel
    ...
    MyLabel:
    ...
    End Sub

    If you call MyProc without specifying Jump, it will execute normally, but if you call it with Jump:=True, execution will jump to the label:

    MyProc MyArg:=37, Jump:=True
    or
    MyProc 37, True

  3. #3
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Call out specfic part of routine (A2002)

    Thanks Hans,
    That's interesting. I am getting more into the habit of creating procedures that are more global and just calling them when needed. I will keep this scenario in mind.

    Thanks,
    Mark

Posting Permissions

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