Change Do/Loop to break then continue after so many iterations?

E

Ed from AZ

Right now my code is set up to run a Do/Loop until all iterations are
completed, then execute more code. I have realized that if the number
of iterations is very large, I will need to break things up into
smaller chunks. If the total iteratins is 100, for instance, I wiil
need to run the loop 20 times, execute the code, loop 20 more,
execute, etc etc. For some reason, I can't seem to get my brain
moving on this. A drop-kick in the right direction would be
appreciated.

I currently have:

y = Total_Iterations
x = 1

Do
' Some_code
x = x + 1
Loop Until x = y

' Execute_this

I need to change to:

y = Total_Iterations
x = 1

If y > 20

Do
' Some_code
x = x + 1
Loop Until x = 20

' Execute_this

' Go back for 20 more and execute again
' until y has been reached.

Ed
 
K

Klaus Linke

Hi Ed,

You could use the Mod operator to run some code every 20th iteration:

y = Total_Iterations
x = 1

Do
Some_code
If (x mod 20) = 0 then
Execute_this
Endif
x = x + 1
Loop Until x = y

Regards,
Klaus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top