CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Goto

  1. #1
    Join Date
    Sep 2000
    Posts
    127

    Goto

    Is there a way to do something like this , suppose i am have finished executing a procedure in my module then i want to go to the last line of another procedure in my form. Is this possible?


  2. #2
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    Re: Goto

    You can only branch to another line in the current Subroutine/Procedure. Using GOTO is not a very good solution in any case. What you should do, it break the procedure (where you want to jump to), into another procedure. Call it from both places you need to like....



    public Sub FirstRoutine()

    StuffIWantToDoInFirstRoutine
    Call CommonRoutine

    End Sub

    public Sub SecondRoutine()

    StuffIWantToDoInFirstRoutine
    Call CommonRoutine

    End Sub

    public Sub CommonRoutine()

    StuffIWantToDoInBothRoutines

    End Sub




    After you call the common routine, flow will continue back with the calling procedure.

    Hope this helps


  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Goto

    Excelent answer. If "eng" do not rate it, I do!

    Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

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

Featured