Results 1 to 13 of 13

Thread: changing the point of execution

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2005
    Posts
    1,069

    Resolved changing the point of execution

    Hello
    Cani move the point of execution, i mean if i break the program execution and want the program to start from a certain point can i do it.
    something like place the cursor at some point and start the execution from that point (on the same form of course)

    i know this is possible in assembly language(yes VB and assembly language are like apples and eggs )
    Last edited by vb_student; Jan 25th, 2005 at 12:14 PM.

  2. #2
    Lively Member Tw1sted L0gic's Avatar
    Join Date
    Jan 2005
    Posts
    88

    Re: changing the point of execution

    You mean while in the IDE?

    You can press CTRL + BREAK to break execution, or put a stop point next to a line of code by clicking next to it. then F8 to skip through.

    Or have I misunderstood your question?
    Naughty but Nice

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: changing the point of execution

    If you are already in break mode you can set the next statement to be executed (but only in the same procedure).

    The statement which is about to be executed is shown in yellow, with a little arrow in the left border. You can drag this to another line, or right click on another line (again in the same procedure) and select "Set next statement".

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2005
    Posts
    1,069

    Re: changing the point of execution

    thanks dudes
    i tried to drag it to another form(hehe) but it failed

  5. #5
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: changing the point of execution

    is there anyway to change the point while the program is executing?

    I know you can jump to a different subroutine but the execution returns after that. Is there anyway to make it jump without comming back?
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

  6. #6
    Fanatic Member FireXtol's Avatar
    Join Date
    Apr 2010
    Posts
    874

    Re: changing the point of execution

    Quote Originally Posted by Resilience View Post
    is there anyway to change the point while the program is executing?

    I know you can jump to a different subroutine but the execution returns after that. Is there anyway to make it jump without comming back?
    Sure, if the procedure you call terminates the application via End.

    Otherwise, you could use a function or byref parameter to inform the calling procedure to Exit Sub/Function upon return.

  7. #7
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: changing the point of execution

    I don't know if it will help you but when you are at a breakpoint you can execute any procedure in your app by typing the name of the sub into the Immediate window and pressing return.

  8. #8
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: changing the point of execution

    Otherwise, you could use a function or byref parameter to inform the calling procedure to Exit Sub/Function upon return.
    Yeah thats what i was figuring. I dont know a whole lot about vb6 and its capabilites so i thought i would ask. I use timers to cycle the execution and the way i imagine it is like a tree.

    Each subroutine being a new branch on the trunk, without the execution being able to return through the same route that it came it wont be able to get back to the trunk. Does that make sense? I assume thats how it must work. So you wouldnt be able to go from a subroutine back to the trunk (without returning) otherwise it would create an ever deep endless loop, i guess?
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

  9. #9
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: changing the point of execution

    Resil

    If your Call Stack looks something like this:

    Proj1.Sub3
    Proj1.Sub2
    Proj1.Sub1


    .. and you are currently in Sub3, and upon completion
    .. you want to skip the rest of the code in Sub2,

    you could put an Exit Sub statement in Sub2.

    You would want to do this in an If .. End If branch.
    You would then skip rest of the code in Sub2 and go back to Sub1.

    Is that what you are looking for?

    Spoo

  10. #10
    Fanatic Member FireXtol's Avatar
    Join Date
    Apr 2010
    Posts
    874

    Re: changing the point of execution

    Seems like something for conditional structures, such as IF|THEN or SELECT CASE, etc.

    I don't really follow your trunk analogy... except in terms of conditional constructs.

    General procedural execution is more like a deck of cards(the cards being procedures/subroutines). One is placed on the stack until it fully resolves(completes and sometimes returns a value) and then it is removed. If a procedure calls a subroutine it's added to the stack(on the top). When the subroutine then resolves, it is removed from the stack(the top), and execution resumes with the next card on the stack(again, the top card, which would likely be the calling procedure). VB uses what is essentially a LIFO (last in, first out) stack, or sometimes called FILO (first in, last out).

  11. #11
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: changing the point of execution

    firextol, yeah thats alot like what i was imagining. thanks for the help.

    spoo, thats what i was figuring. Starting at Sub1 and ending up at Sub3 I wanted to go straight back to Sub1 without returning to Sub2. But as you said, i'll have to use a variable.

    I'm making a global variable such as "Public NeedExit as boolean"
    and am going to place it in Sub2 just after the place where i call Sub3. That way i can get back to the original Sub1 that i need without processing Sub2.

    I had an idea that was an option but i was hoping for something better. I have alot of calls to alot of code and it looks "ugly" having those "If NeedExit Then Exit Sub" statments everywhere. I appreciate your guys help and have added to your reputation.
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

  12. #12
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: changing the point of execution

    I just want to make sure you understand that if you execute this code you will see
    This
    is
    a
    test
    Code:
    Private Sub Form_Load()
    Sub1
    MsgBox "test"
    End Sub
    Public Sub Sub1()
    MsgBox "This"
    Sub2
    End Sub
    Public Sub Sub2()
    MsgBox "is"
    Sub3
    End Sub
    Public Sub Sub3()
    MsgBox "a"
    End Sub

  13. #13
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: changing the point of execution

    Quote Originally Posted by MartinLiss View Post
    Code:
    Private Sub Form_Load()
    Sub1
    MsgBox "test"
    End Sub
    Public Sub Sub1()
    MsgBox "This"
    Sub2
    End Sub
    Public Sub Sub2()
    MsgBox "is"
    Sub3
    End Sub
    Public Sub Sub3()
    MsgBox "a"
    End Sub

    Yeah I understand. Basically what im doing is:
    VB Code:
    1. public NeedExit as boolean
    2. dim TempString as string
    3.  
    4. Private Sub Form_Load()
    5.  Sub1
    6.  TempString = TempString  & "test"
    7. End Sub
    8.  
    9. Public Sub Sub1()
    10.  TempString = TempString  & "This"
    11.  Sub2
    12. End Sub
    13. Public Sub Sub2()
    14.  TempString = TempString  & "is"
    15.  Sub3
    16.  If NeedExit Then Exit Sub
    17.  TempString = TempString  & "longer"
    18. End Sub
    19. Public Sub Sub3()
    20.  TempString = TempString  & "a"
    21.  if TempString = "This is a" then
    22.   NeedExit = True
    23.   exit sub
    24.  End If
    25. End Sub

    So i'll get the execution back to form_load with my string being "This is a test" instead of the string being "This is a longer test"
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

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