-
February 15th, 2010, 03:44 AM
#1
[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.
-
February 15th, 2010, 05:55 AM
#2
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 !
-
February 15th, 2010, 08:13 AM
#3
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.
-
February 15th, 2010, 09:37 AM
#4
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.
-
February 15th, 2010, 11:18 AM
#5
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.
-
February 15th, 2010, 12:27 PM
#6
Re: Loop Debugging Issue
In that case a simple if statement with a breakpoint inside would do the trick
-
February 15th, 2010, 02:09 PM
#7
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.
-
February 15th, 2010, 06:56 PM
#8
Re: Loop Debugging Issue
Originally Posted by WoF
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
-
February 16th, 2010, 03:12 AM
#9
Re: [RESOLVED] Loop Debugging Issue
I prefer MOD 100 (or whatever). Let the counter go as high as it can
-
February 22nd, 2010, 12:00 AM
#10
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 22nd, 2010 at 12:02 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|