[RESOLVED] Loop Debugging Issue
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: [RESOLVED] Loop Debugging Issue

  1. #1
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    [RESOLVED] Loop Debugging Issue

    here in the following Code .Last value is 9000.When i debug suppose i=1 and cursor is on next .when i press f8 during debugging using f8.it goes on mcol.remove 1.again it becomes i=2
    at the next time.and when press f8 it goes on mcol.remove 1. but i simple want to go if i want to
    go on i=5000.not till i wait i increase upto 1,2,3....5000. is their any way to go directly on any specific number suppose i want to skip loop and i want to go directly on i=8500.Kindly let me know the idea.Any help would be highly appreciated.
    Code:
    Public Function RemoveAll() As Boolean
    Dim i As Integer, last As Integer
    last = mCol.Count
    For i = 1 To last
       mCol.Remove 1
    Next
    End Function
    Last edited by firoz.raj; March 24th, 2010 at 03:28 AM.

  2. #2
    Join Date
    Oct 2006
    Posts
    327

    Re: Loop Debugging Issue

    Hello,
    If, as we can guess it, you destroy a line, you need to loop from the bottom to the top !
    Code:
    For i =  last ti i step -1
    If you do'nt, you will obviously refer to a non existing line !

  3. #3
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,722

    Re: Loop Debugging Issue

    That is not true, becaus he always removes column 1 and not column i.

    But I think this was not the question...
    You can set a breakpoint after the Next and then run until the breakpoint is encountered.
    Although I have not yet worked with them, there are watched variables, as I recall, where you can set to break when a specific value is encountered.

  4. #4
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,836

    Re: Loop Debugging Issue

    As coded I do not see what good it would do you to skip to any specific number since you are always removing item 1 no matter what the variable = to. If you want to remove only 50 or 100 or whatever you could simply change the value of last at the top of the loop.

  5. #5
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,722

    Re: Loop Debugging Issue

    I think he just wants to 'skip' single stepping through the loop, not skipping execution, but continuing single stepping after say 8000 steps, without having to singlestep through all of it.

  6. #6
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,836

    Re: Loop Debugging Issue

    In that case a simple if statement with a breakpoint inside would do the trick

  7. #7
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,722

    Re: Loop Debugging Issue

    Yes, an If statement within the loop like
    Code:
    If i = 8000 Then
      debug.print i
    End If
    would allow to set a breakpoint to the debug.print i and let the loop run.
    But I think setting a breakpoint after the Next does neatly. Why would you stop after 800 deletes and then go on single stepping. The deletes will work to the end, sure.
    So you can resume single stepping after the loop.

  8. #8
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,537

    Re: Loop Debugging Issue

    Quote Originally Posted by WoF View Post
    Yes, an If statement within the loop like
    Code:
    If i = 8000 Then
      debug.print i
    End If
    Yes this is the way to stop at a defined point.
    Your whole code would look like
    Code:
    Public Function RemoveAll() As Boolean
    Dim i As Integer, last As Integer
    last = mCol.Count
    For i = 1 To last
       if i = 8000 then
         Debug.print i
       end if
       mCol.Remove 1
    Next
    End Function
    And set F9 at the shown brown line
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  9. #9
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,982

    Re: [RESOLVED] Loop Debugging Issue

    I prefer MOD 100 (or whatever). Let the counter go as high as it can
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  10. #10
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,836

    Re: [RESOLVED] Loop Debugging Issue

    With the mod function you can check to see if it is = to 0 and have it stop every 100 loops or whatever you choose to use in the mod statement. Just depends on what you want to do.
    Code:
    If i  mod 100= 0 Then
         Debug.Print i
       End If
    Would stop at loop 100 then you could step through one or two if you like and hit F5 and it would stop again at 200 and again at 300 and so on.

    Again just depnds on what you want to do
    Last edited by DataMiser; February 21st, 2010 at 11:02 PM.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center