{"id":1005,"date":"2008-10-12T19:57:29","date_gmt":"2008-10-13T02:57:29","guid":{"rendered":"http:\/\/members.crystalreportsbook.com\/books\/?p=1005"},"modified":"2008-10-12T20:00:33","modified_gmt":"2008-10-13T03:00:33","slug":"812-for-next-loop-while-do-loops","status":"publish","type":"post","link":"http:\/\/www.crystalreportsonlinetraining.com\/training\/812-for-next-loop-while-do-loops\/","title":{"rendered":"8.11 For Next Loop, While-Do Loops"},"content":{"rendered":"<h1>Looping Structures<\/h1>\n<p>Looping structures let you execute a block of code multiple times. The number of times this code block is executed depends upon the type of loop used and what happens within the code block. The looping structures covered are: For Next, While, and the various Do loops.<\/p>\n<h2>For Next Loop<\/h2>\n<p>The For Next loop uses the standard VB .NET syntax of using the For statement followed by a variable and the start and ending range. You have to decide in advance how many times the code block gets executed.<\/p>\n<p>The default loop increment is 1. Use the Step keyword to define a new increment. Terminate the For block using the Next statement. Putting the variable name after the Next statement is optional. You can prematurely exit the loop by using the Exit For statement.<\/p>\n<p><code>For var = start To end Step increment<\/code><br \/>\n<code>...code...<\/code><br \/>\n<code>If condition Then<\/code><br \/>\n<code>Exit For<\/code><br \/>\n<code>End If<\/code><br \/>\n<code>Next<\/code><\/p>\n<h2>While and Do Loops<\/h2>\n<p>The While and Do loops all follow the standard VB .NET syntax. The While block is terminated with a Wend statement. The Do loops are terminated with a Loop statement. The While keyword is used to continue looping as long as the condition evaluates to True. The Until keyword is used to continue looping when a condition evaluates to False. You can exit a Do loop with an Exit Do statement.<\/p>\n<p>Code template for While \u2026 Wend:<\/p>\n<p><code>While true_condition<\/code><br \/>\n<code>...code...<\/code><br \/>\n<code>Wend<\/code><\/p>\n<p>Code template for Do While \u2026 Loop:<\/p>\n<p><code>Do While true_condition<\/code><br \/>\n<code>...code...<\/code><br \/>\n<code>Loop<\/code><\/p>\n<p>Code template for Do Until \u2026 Loop:<\/p>\n<p><code>Do Until false_condition<\/code><br \/>\n<code>...code...<\/code><br \/>\n<code>Loop<\/code><\/p>\n<p>Code template for Do \u2026 Loop While:<\/p>\n<p><code>Do<\/code><br \/>\n<code>...code...<\/code><br \/>\n<code>Loop While true_condition<\/code><\/p>\n<p>Code template for Do \u2026 Loop Until:<\/p>\n<p><code>Do<\/code><br \/>\n<code>...code...<\/code><br \/>\n<code>Loop Until false_condition<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Looping Structures Looping structures let you execute a block of code multiple times. The number of times this code block is executed depends upon the type of loop used and what happens within the code block. The looping structures covered are: For Next, While, and the various Do loops. For Next Loop The For Next [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[54,40],"tags":[],"class_list":["post-1005","post","type-post","status-publish","format-standard","hentry","category-chapter-8-learning-basic-syntax","category-crystal-reportsnet-2008","entry"],"_links":{"self":[{"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/posts\/1005","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/comments?post=1005"}],"version-history":[{"count":0,"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/posts\/1005\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/media?parent=1005"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/categories?post=1005"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/tags?post=1005"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}