Results 1 to 7 of 7

Thread: Calling subs

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 1999
    Location
    Reynosa, Mexico
    Posts
    274
    From within Sub1 I call to Sub2, from there Icall to Sub3 This is:

    Sub1->Sub2->Sub3

    The back way must be: Sub3->Sub2->Sub1

    But the back way it takes is Sub3->Sub1 and all the code after I called the Sub3 is omitted!!

    Sub1 is into a Form and Sub2 and Sub3 are into a Module.

  2. #2
    Guest
    Code:
    Sub One
        Print "Sub1Start"
        Call Two
        Print "Sub1End"
    End Sub
    
    Sub Two
        Print "Sub2Start"
        Call Three
        Print "Sub2End"
    End Sub
    
    Sub Three
        Print "Sub3Start"
        Print "Sub3End"
    End Sub
    Your code:
    Code:
    Call One
    It should output like this:
    Sub1Start
    Sub2Start
    Sub3Start
    Sub3End
    Sub2End
    Sub1End

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 1999
    Location
    Reynosa, Mexico
    Posts
    274
    That is the result I must get but the real result I get is (into my complete code) :

    Sub1Start
    Sub2Start
    Sub3Start
    Sub3End
    Sub1End

    It omits the Sub2End.

    Obviously I must have anything into my code so that I get this rare result, but What could it be the problem?
    Ulises Vázquez
    [size=1.7]Oracle DBA Certified Professioanl
    Visual Basic 6 Developer
    Crystal Reports Designer
    [/size]

  4. #4
    Guest
    Are you sure you don't have an exit sub statement somehwere in your second sub?

    Try this: Create a new project, add the code I gave you into a button, press the button and post the results.

  5. #5
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357
    Or step through your code and watch what happens using the debugger. An error handler or GoTo may also be the culprit.
    ~seaweed

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    May 1999
    Location
    Reynosa, Mexico
    Posts
    274
    Megatron, seaweed:

    I did what you say, from the End Sub line of the Sub3, it jumps to the next line on Sub1

    Of course I I oen a new project and put the code that Megatron gave me, it works. The problem is not constant, is an extrange behavior just into my actual program.

    I traced it several times and I apparently don't have any exit sub or another statament that make this rare behavior.

  7. #7
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357
    Post the subs. (If they are too big to post, zip them and attach them to your post).

    We will get to the bottom of this!!
    ~seaweed

Posting Permissions

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



Click Here to Expand Forum to Full Width