![]() |
|
|
Nested Loop, a Loop within a LoopA nested loop is a loop within a loop. The first run through of the outer loop triggers the inner loop which loops through until finished. Then the second run through of the outer loop triggers the inner loop again which loops through until finished again. This process will repeat until the outer loop finishes its loop sequence. The code below has two For Next Loops. Our loop counter variables
OuterLoop and InnerLoop both begin at 1 and end at 3 incrementing by
1 each time they pass through their respective Next Statement. <% Below is the above code in action: OuterLoop= 1 InnerLoop = 1 OuterLoop= 1 InnerLoop = 2 OuterLoop= 1 InnerLoop = 3 OuterLoop= 2 InnerLoop = 1 OuterLoop= 2 InnerLoop = 2 OuterLoop= 2 InnerLoop = 3 OuterLoop= 3 InnerLoop = 1 OuterLoop= 3 InnerLoop = 2 OuterLoop= 3 InnerLoop = 3 If you have any code snippets to share with full credit given then send an email to Codesnippets - You'll receive full credit and a link back to your site. Site developed by Michael Wall - Web Design Belfast N.Ireland. |
|