Looping Through Code, Looping allows you to run a group of statements repeatedly.
Do Loop Do...Loop to run a block of statements While a Condition is True Do While IntMyInteger > 10 IntMyInteger = IntMyInteger - 1 Loop or Do IntMyInteger = IntMyInteger - 1 Loop While IntMyInteger > 10 Do...Loop to run a block of statements Until a Condition Becomes True Do Until IntMyInteger = 10 IntMyInteger = IntMyInteger - 1 Loop or Do IntMyInteger = IntMyInteger + 1 Loop Until IntMyInteger = 10 Exit a Do...Loop from inside the Loop with the Exit Do statement. For...Next For...Next to run statements a specific number of times. For IntMyInteger = 1 To 50 MyProcedure Next This can be modified with a positive or negative Step value For IntMyInteger = 50 To 1 step -5 MyProcedure Next Exit a For...Next statement prematurely with the Exit For statement. For Each...Next A For Each...Next loop repeats a group of statements for each item in a collection of objects or for each element of an array. While...Wend Conditionally repeat a block of statements: While second(Time()) > 30 WScript.Echo "This line will repeat for 30 seconds" Wend
“It's a good rule to follow the first law of holes: If you are in one, stop digging” ~ Denis Healey