{"id":65157,"date":"2022-06-24T10:01:53","date_gmt":"2022-06-24T10:01:53","guid":{"rendered":"https:\/\/itsourcecode.com\/?p=65157"},"modified":"2023-11-21T05:44:31","modified_gmt":"2023-11-21T05:44:31","slug":"vb-net-loops","status":"publish","type":"post","link":"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-loops\/","title":{"rendered":"VB.net Loops &#8211; For Each, Do While, While End, For Next"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"h-what-is-vb-net-loops\"><strong>What is VB.net Loops?<\/strong><\/h2>\n\n\n\n<p>A <strong>VB.net Loops <\/strong>or looping statement is used to repeat the same process multiple times until it meets the specified condition in a program. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>By using a <strong>loop <\/strong>in a program, a programmer can repeat any number of statements up to the desired number of repetitions.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>There can be instances where you need to run a block of code repeatedly. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>The first statement in a function is executed first, then the second, and so on. In general, statements are executed in order.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>The general form of a loop statement in most programming languages is as follows. A loop statement allows us to run a statement or collection of statements several times.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-vb-net-loops-flow-chart\"><strong>VB.net Loops Flow Chart<\/strong>:<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/VB-NET-Loops-Diagram.png\"><img loading=\"lazy\" decoding=\"async\" width=\"707\" height=\"658\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/VB-NET-Loops-Diagram.png\" alt=\"VB NET Loops Diagram\" class=\"wp-image-65172\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/VB-NET-Loops-Diagram.png 707w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/VB-NET-Loops-Diagram-300x279.png 300w\" sizes=\"auto, (max-width: 707px) 100vw, 707px\" \/><\/a><figcaption class=\"wp-element-caption\">VB NET Loops Diagram<\/figcaption><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-types-of-loop-in-vb-net\"><strong>Types of Loop in VB.net<\/strong><\/h2>\n\n\n\n<p><strong>VB.net<\/strong> provides the following <strong>types of loops<\/strong> to handle looping requirements.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Loop Types in VB.net<\/th><th>Description<\/th><\/tr><tr><td>Do Loop<\/td><td>It repeats the enclosed block of statements while a Boolean condition is True or until the condition becomes True. It could be terminated at any time with the Exit Do statement.<\/td><\/tr><tr><td>For&#8230;Next<\/td><td>It repeats a group of statements a specified number of times and a loop index counts the number of loop iterations as the loop executes.<\/td><\/tr><tr><td>For Each&#8230;Next<\/td><td>It repeats a group of statements for each element in a collection. This loop is used for accessing and manipulating all elements in an array or a VB.Net collection.<\/td><\/tr><tr><td>While&#8230; End While<\/td><td>It executes a series of statements as long as a given condition is True.<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\"><strong><em>Types of Loop in VB.net<\/em><\/strong><\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-do-loop-in-vb-net\"><strong>Do Loop in VB.net<\/strong><\/h3>\n\n\n\n<p>The <strong>Do While loop In VB.NET<\/strong> is used to execute blocks of statements in the program, as long as the condition remains true. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>It is similar to the <strong>While End Loop<\/strong>, but there is a slight difference between them. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>The <strong>while loop<\/strong> initially checks the defined condition, if the condition becomes true, the while loop&#8217;s statement is executed. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Whereas in the <strong>Do loop<\/strong>, is the opposite of the while loop, which means that it executes the <strong>Do statements<\/strong>, and then it checks the condition.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-syntax\"><strong>Syntax:<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>Do  \n&#91; Statements to be executed]  \nLoop While Boolean_expression  \n\/\/ or  \nDo   \n&#91;Statement to be executed]  \nLoop Until Boolean_expression  <\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>In the above syntax, the Do keyword follows a block of statements, and the While keyword checks <strong>Boolean_expression<\/strong> after the execution of the first Do statement.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-data-flow-diagram\"><strong> Data Flow Diagram:<\/strong><\/h4>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Do-Loop-Data-Flow-Diagram-in-VB-NET.png\"><img loading=\"lazy\" decoding=\"async\" width=\"912\" height=\"803\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Do-Loop-Data-Flow-Diagram-in-VB-NET.png\" alt=\"Do Loop Data Flow Diagram in VB NET\" class=\"wp-image-65189\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Do-Loop-Data-Flow-Diagram-in-VB-NET.png 912w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Do-Loop-Data-Flow-Diagram-in-VB-NET-300x264.png 300w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Do-Loop-Data-Flow-Diagram-in-VB-NET-768x676.png 768w\" sizes=\"auto, (max-width: 912px) 100vw, 912px\" \/><\/a><figcaption class=\"wp-element-caption\">Do Loop Data Flow Diagram in VB NET<\/figcaption><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<p>The above flow chart represents the flow of the <strong>Do While loop<\/strong>. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>It is used to control the flow of statements, such that it executes the statement at least once before checking the While or Until condition. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>If the condition is true, the next iteration will be executed till the condition becomes false.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-example-program-of-do-loop-in-vb-net\"><strong>Example Program of Do Loop in VB.net<\/strong><\/h4>\n\n\n\n<p><strong>Example 1<\/strong>. Write a simple program to print a number from <strong>1<\/strong> to <strong>10<\/strong> using the <strong>Do While loop in VB.net<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Imports System  \nModule Do_loop  \n    Sub Main()  \n        ' Initializatio and Declaration of variable i  \n        Dim i As Integer = 1  \n        Do  \n            ' Executes the following Statement  \n            Console.WriteLine(\" Value of variable I is : {0}\", i)  \n            i = i + 1 'Increment the variable i by 1  \n        Loop While i &lt;= 10 ' Define the While Condition  \n  \n        Console.WriteLine(\" Press any key to exit...\")  \n        Console.ReadKey()  \n    End Sub  \nEnd Module  <\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>When the above code is compiled and executed, it produces the following result:<\/p>\n\n\n\n<p class=\"has-base-3-color has-contrast-background-color has-text-color has-background\">Value of variable I is : 1<br>Value of variable I is : 2<br>Value of variable I is : 3<br>Value of variable I is : 4<br>Value of variable I is : 5<br>Value of variable I is : 6<br>Value of variable I is : 7<br>Value of variable I is : 8<br>Value of variable I is : 9<br>Value of variable I is : 10<br>Press any key to exit\u2026<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>In the above program, the <strong>Do While loop<\/strong> executes the body until the given condition becomes <strong><em>false<\/em><\/strong>. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>When the condition becomes <em><strong>false<\/strong><\/em> the loop will be terminated.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>You can test the above example here! \u27a1&nbsp;<a href=\"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-online-compiler-and-ide\/\">VB.net Online Compiler<\/a><\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-for-the-next-loop-in-vb-net\"><strong>For the Next Loop in VB.net<\/strong><\/h3>\n\n\n\n<p>A <strong>For Next loop in VB.net<\/strong> is used to repeatedly execute a sequence of code or a block of code until a given condition is satisfied. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>A <strong>For loop<\/strong> is useful in such a case when we know how many times a block of code has to be executed. In VB.NET, the<strong> For loop<\/strong> is also known as <strong>For Next Loop<\/strong>.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-syntax-0\"><strong>Syntax:<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>'syntax of for next loop'\n\nFor variable_name As &#91; DataType ] = start To end &#91; Step step ]  \n&#91; Statements to be executed ]  \nNext  <\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Let&#8217;s Understand the Next Loop in Detail.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>For<\/strong>: It is the keyword that is present at the beginning of the definition.<\/li>\n<\/ol>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li><strong>variable_name<\/strong>: It is a variable name, which is required in the For loop Statement. The value of the variable determines when to exit from the <strong>For-Next loop<\/strong>, and the value should only be numeric.<\/li>\n<\/ol>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li><strong>[Data Type]<\/strong>: It represents the Data Type of the <strong>variable_name<\/strong>.<\/li>\n<\/ol>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\">\n<li><strong>start To end<\/strong>: The start and end are the two important parameters representing the initial and final values of the <strong>variable_name<\/strong>. \n\n\n\n\n<ul class=\"wp-block-list\">\n<li>These parameters are helpful while the execution begins, the initial value of the variable is set by the start. Before the completion of each repetition, the variable&#8217;s current value is compared with the end value. <\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>And if the value of the variable is less than the end value, the execution continues until the variable&#8217;s current value is greater than the end value. And if the value is exceeded, the loop is terminated.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\">\n<li><strong>Step<\/strong>: A step parameter is used to determine by which the counter value of a variable is increased or decreased after each iteration in a program. If the counter value is not specified; It uses 1 as the default value.<\/li>\n<\/ol>\n\n\n\n<ol class=\"wp-block-list\" start=\"6\">\n<li><strong>Statements<\/strong>: A statement can be a single statement or group of statements that execute during the completion of each iteration in a loop.<\/li>\n<\/ol>\n\n\n\n<ol class=\"wp-block-list\" start=\"7\">\n<li><strong>Next<\/strong>: In VB.net a Next is a keyword that represents the end of the For loop&#8217;s<\/li>\n<\/ol>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-data-flow-diagram-0\"><strong>Data Flow Diagram<\/strong>:<\/h4>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/For-Next-Loop-Data-Flow-Diagram-in-VB-NET.png\"><img loading=\"lazy\" decoding=\"async\" width=\"791\" height=\"797\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/For-Next-Loop-Data-Flow-Diagram-in-VB-NET.png\" alt=\"For Next Loop Data Flow Diagram in VB NET\" class=\"wp-image-65216\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/For-Next-Loop-Data-Flow-Diagram-in-VB-NET.png 791w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/For-Next-Loop-Data-Flow-Diagram-in-VB-NET-298x300.png 298w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/For-Next-Loop-Data-Flow-Diagram-in-VB-NET-150x150.png 150w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/For-Next-Loop-Data-Flow-Diagram-in-VB-NET-768x774.png 768w\" sizes=\"auto, (max-width: 791px) 100vw, 791px\" \/><\/a><figcaption class=\"wp-element-caption\">For Next Loop Data Flow Diagram in VB NET<\/figcaption><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<p>In the above flow chart, the first step is to initialize the variable name with the start value. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Then, the value of the variable will be compared to the end expression or value. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>If the condition is true, the control enters the loop body and executes the statements. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>After that, the value of a variable will be automatically incremented by the compiler. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Upon completion of each iteration, the current value of a variable will be again compared to the end expression. If the condition is not true, the controlled exit from the loop.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-example-program-of-for-next-loop-in-vb-net\"><strong>Example Program of For Next Loop in VB.net<\/strong><\/h4>\n\n\n\n<p><strong>Example 1<\/strong>. Write a simple program to print the number from 1 to 10 using the For Next loop.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Imports System  \nModule Number  \n    Sub Main()  \n        ' It is a simple print statement, and 'vbCrLf' is used to jump in the next line.  \n        Console.Write(\" The number starts from 1 to 10 \" &amp; vbCrLf)  \n        ' declare and initialize variable i  \n        For i As Integer = 1 To 10 Step 1  \n            ' if the condition is true, the following statement will be executed  \n            Console.WriteLine(\" Number is {0} \", i)  \n            ' after completion of each iteration, next will update the variable counter  \n        Next  \n        Console.WriteLine(\" Press any key to exit... \")  \n        Console.ReadKey()  \n    End Sub  \nEnd Module<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>When the above code is compiled and executed, it produces the following result:<\/p>\n\n\n\n<p class=\"has-base-3-color has-contrast-background-color has-text-color has-background\">The number starts from 1 to 10<br>Number is 1<br>Number is 2<br>Number is 3<br>Number is 4<br>Number is 5<br>Number is 6<br>Number is 7<br>Number is 8<br>Number is 9<br>Number is 10<br>Press any key to exit\u2026<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>In the above example, we have initialized an integer variable i with an initial value of 1. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>The <strong>For loop<\/strong> will continuously execute its body until the value of <strong>i<\/strong> is smaller or <strong>equal to 10<\/strong>. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>After each iteration, the value of <strong>i<\/strong> is automatically increased with &#8216;<strong>Step 1<\/strong>&#8216;. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>If the value of <strong>i<\/strong> reached <strong>10<\/strong>, the loop would be terminated, and the control transfer to the <strong>Main() function<\/strong>.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>You can test the above example here! \u27a1&nbsp;<a href=\"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-online-compiler-and-ide\/\">VB.net Online Compiler<\/a><\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-for-each-loop-in-vb-net\"><strong>For Each Loop in VB.net<\/strong><\/h3>\n\n\n\n<p><strong>For Each loop In the VB.net<\/strong> is used to iterate a block of statements in an array or collection of objects. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Using For Each loop, we can easily work with collection objects such as lists, arrays, etc., to execute each element of an array or in a collection. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>When iteration through each element in the array or collection is complete, the control is transferred to the next statement to end the loop.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-syntax-1\"><strong>Syntax<\/strong>:<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>'syntax of for each loop'\n\nFor Each var_name As &#91; DataType ] In Collection_Object  \n&#91; Statements to be executed]  \nNext  <\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>For Each loop<\/strong> is used to read each element from the collection object or an array. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>The <strong>Data Type<\/strong> represents the type of the variable, and <strong>var_name<\/strong> is the name of the variable to access elements from the array or collection object so that it can be used in the body of <strong>For Each loop<\/strong>.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-data-flow-diagram-1\"><strong>Data Flow Diagram:<\/strong><\/h4>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/For-Each-Loop-Data-Flow-Diagram-in-VB-NET.png\"><img loading=\"lazy\" decoding=\"async\" width=\"866\" height=\"744\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/For-Each-Loop-Data-Flow-Diagram-in-VB-NET.png\" alt=\"For Each Loop Data Flow Diagram in VB NET\" class=\"wp-image-65276\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/For-Each-Loop-Data-Flow-Diagram-in-VB-NET.png 866w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/For-Each-Loop-Data-Flow-Diagram-in-VB-NET-300x258.png 300w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/For-Each-Loop-Data-Flow-Diagram-in-VB-NET-768x660.png 768w\" sizes=\"auto, (max-width: 866px) 100vw, 866px\" \/><\/a><figcaption class=\"wp-element-caption\">For Each Loop Data Flow Diagram in VB NET<\/figcaption><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<p>The first step is to initialize an array or collection object to execute each element of the array with the help of variables in <strong>For Each loop<\/strong>.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p> A variable is used in For Each loop to check whether the element is available or not. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>If the element is available in the collection object, the <strong>For Each<\/strong> block will be executed until the condition remains true. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>After the execution of each element of an array, the control transfers to the end statement.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-example-program-of-for-each-loop-in-vb-net\"><strong>Example Program of For Each Loop in VB.net<\/strong><\/h4>\n\n\n\n<p><strong>Example 1<\/strong>: Write a simple program to understand the uses of <strong>For Each Next loop in VB.net<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Imports System  \nModule For_Each_loop  \n    Sub Main()  \n        'declare and initialize an array as integer  \n        Dim An_array() As Integer = {1, 2, 3, 4, 5}  \n        Dim i As Integer 'Declare i as Integer  \n  \n        For Each i In An_array  \n            Console.WriteLine(\" Value of i is {0}\", i)  \n        Next  \n        Console.WriteLine(\"Press any key to exit...\")  \n        Console.ReadLine()  \n    End Sub  \nEnd Module  <\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>When the above code is compiled and executed, it produces the following result:<\/p>\n\n\n\n<p class=\"has-base-3-color has-contrast-background-color has-text-color has-background\">Value of i is 1<br>Value of i is 2<br>Value of i is 3<br>Value of i is 4<br>Value of i is 5<br>Press any key to exit\u2026<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>In the above example, we create an integer array with the name An_array (), and For Each loop is used to iterate each element of the array with the help of the defined variable &#8216;<strong>i<\/strong>&#8216;.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>You can test the above example here! \u27a1&nbsp;<a href=\"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-online-compiler-and-ide\/\">VB.net Online Compiler<\/a><\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-while-end-loop-in-vb-net\"><strong>While End Loop in VB.net<\/strong><\/h3>\n\n\n\n<p>The <strong>While End loop in VB.net<\/strong> is used to execute blocks of code or statements in a program, as long as the given condition is <strong><em>true<\/em><\/strong>. It is useful when the number of executions of a block is not known.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>It is also known as an entry-<strong>controlled loop statement<\/strong>, which means it initially checks all loop conditions. If the condition is <strong><em>true<\/em><\/strong>, the body of the <strong>while loop<\/strong> is executed. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>This process of repeated execution of the body continues until the condition is not <strong><em>false<\/em><\/strong>. And if the condition is <strong><em>false<\/em><\/strong>, control is transferred out of the loop.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-syntax-2\"><strong>Syntax<\/strong>:<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>'syntax of while end loop'\n\nWhile &#91;condition]  \n    &#91; Statement to be executed ]  \nEnd While  <\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Here, the<strong> condition<\/strong> represents any <strong>Boolean condition<\/strong>, and if the <strong>logical condition<\/strong> is <strong><em>true<\/em><\/strong>, the single or block of <strong>statements<\/strong> defined inside the body of the <strong>while loop<\/strong> is executed.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-data-flow-diagram-2\"><strong>Data Flow Diagram<\/strong>:<\/h4>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/While-End-Loop-Data-Flow-Diagram-in-VB-NET.png\"><img loading=\"lazy\" decoding=\"async\" width=\"911\" height=\"798\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/While-End-Loop-Data-Flow-Diagram-in-VB-NET.png\" alt=\"While End Loop Data Flow Diagram in VB NET\" class=\"wp-image-65314\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/While-End-Loop-Data-Flow-Diagram-in-VB-NET.png 911w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/While-End-Loop-Data-Flow-Diagram-in-VB-NET-300x263.png 300w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/While-End-Loop-Data-Flow-Diagram-in-VB-NET-768x673.png 768w\" sizes=\"auto, (max-width: 911px) 100vw, 911px\" \/><\/a><figcaption class=\"wp-element-caption\">While End Loop Data Flow Diagram in VB NET<\/figcaption><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<p>As we know, the <strong>While End loop<\/strong> is an entry-controlled loop used to determine if the condition is <strong><em>true<\/em><\/strong>, the statements defined in the body of the loop are executed, and the execution process continues till the condition is satisfied. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Furthermore, after each iteration, the value of the counter variable is incremented. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>It again checks whether the defined condition is <strong><em>true<\/em><\/strong>; And if the condition is again <strong><em>true<\/em><\/strong>, the body of the <strong>While loop<\/strong> is executed. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>And when the condition is not true, the control is transferred to the end of the loop.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-example-program-of-while-end-loop-in-vb-net\"><strong>Example Program of While End Loop in VB.net<\/strong>:<\/h4>\n\n\n\n<p><strong>Example 1<\/strong>: Write a simple program to print the number from 1 to 10 using t<strong>he While End loop in VB.net<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Imports System  \nModule while_number  \n    Sub Main()  \n        'declare x as an integer variable  \n        Dim x As Integer  \n        x = 1  \n        ' Use While End condition  \n        While x &lt;= 10  \n            'If the condition is true, the statement will be executed.  \n            Console.WriteLine(\" Number {0}\", x)  \n            x = x + 1 ' Statement that change the value of the condition  \n        End While  \n        Console.WriteLine(\" Press any key to exit...\")  \n        Console.ReadKey()  \n    End Sub  \nEnd Module  <\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>When the above code is compiled and executed, it produces the following result:<\/p>\n\n\n\n<p class=\"has-base-3-color has-contrast-background-color has-text-color has-background\">Number 1<br>Number 2<br>Number 3<br>Number 4<br>Number 5<br>Number 6<br>Number 7<br>Number 8<br>Number 9<br>Number 10<br>Press any key to exit\u2026<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>In the above example, <strong>while loop<\/strong> executes its body or statement up to the defined state <strong>(i &lt;= 10)<\/strong>. When the value of the variable <strong>i<\/strong> is <strong>11<\/strong>, the defined condition will be <strong><em>false<\/em><\/strong>; the loop will be terminated.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>You can test the above example here! \u27a1&nbsp;<a href=\"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-online-compiler-and-ide\/\">VB.net Online Compiler<\/a><\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-summary\"><strong>Summary<\/strong><\/h2>\n\n\n\n<p>For this tutorial, we already discussed the different types of Loops in VB.net and their meanings, examples, and uses in different ways.<\/p>\n\n\n\n<p><strong><strong><strong><a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/visual-basic\/\">VB.net<\/a><\/strong><\/strong> loop structures<\/strong> allow you to run one or more lines of code repetitively. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>You can repeat the statements in a loop structure until a condition is True until a condition is False, a specified number of times, or once for each element in a collection.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div class=\"wp-block-columns is-not-stacked-on-mobile tw-mb-0 tw-mt-0 tw-gutter-large tw-stretched-link is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"tw-mt-0 tw-mb-0\" style=\"font-size:22px;font-style:normal;font-weight:600\"><strong>PREVIOUS<\/strong><\/p>\n\n\n\n<div class=\"wp-block-cover tw-mt-0 tw-mb-0 is-style-tw-rounded-corners tw-stretched-link tw-hover-show-text tw-ratio-16-9\"><span aria-hidden=\"true\" class=\"wp-block-cover__background has-background-dim-70 has-background-dim\"><\/span><img loading=\"lazy\" decoding=\"async\" width=\"1460\" height=\"900\" class=\"wp-block-cover__image-background wp-image-64913\" alt=\"VB NET Operators\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/VB-NET-Operators.png\" style=\"object-position:50% 50%\" data-object-fit=\"cover\" data-object-position=\"50% 50%\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/VB-NET-Operators.png 1460w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/VB-NET-Operators-300x185.png 300w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/VB-NET-Operators-1024x631.png 1024w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/VB-NET-Operators-768x473.png 768w\" sizes=\"auto, (max-width: 1460px) 100vw, 1460px\" \/><div class=\"wp-block-cover__inner-container is-layout-flow wp-block-cover-is-layout-flow\">\n<p class=\"has-text-align-center tw-mt-0 tw-mb-0 has-base-3-color has-text-color\" style=\"font-size:30px\"><strong><a href=\"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-operators-how-many-types-of-operators-used-in-vb-net\/\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-base-3-color\">Operators<\/mark><\/a><\/strong><\/p>\n<\/div><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"has-text-align-right tw-mt-0 tw-mb-0\" style=\"font-size:22px;font-style:normal;font-weight:600\"><strong>NEXT <\/strong><\/p>\n\n\n\n<div class=\"wp-block-cover tw-mt-0 tw-mb-0 is-style-tw-rounded-corners tw-stretched-link tw-hover-show-text tw-ratio-16-9\"><span aria-hidden=\"true\" class=\"wp-block-cover__background has-background-dim-70 has-background-dim\"><\/span><img loading=\"lazy\" decoding=\"async\" width=\"1460\" height=\"900\" class=\"wp-block-cover__image-background wp-image-65334\" alt=\"Strings in VB NET\" src=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Strings-in-VB-NET.png\" data-object-fit=\"cover\" srcset=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Strings-in-VB-NET.png 1460w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Strings-in-VB-NET-300x185.png 300w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Strings-in-VB-NET-1024x631.png 1024w, https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Strings-in-VB-NET-768x473.png 768w\" sizes=\"auto, (max-width: 1460px) 100vw, 1460px\" \/><div class=\"wp-block-cover__inner-container is-layout-flow wp-block-cover-is-layout-flow\">\n<p class=\"has-text-align-center tw-mt-0 tw-mb-0 has-base-3-color has-text-color\" style=\"font-size:30px\"><strong><a href=\"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/string-in-vb-net-string-function-in-vb-net-with-example\/\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-base-3-color\">Strings<\/mark><\/a><\/strong><\/p>\n<\/div><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>What is VB.net Loops? A VB.net Loops or looping statement is used to repeat the same process multiple times until it meets the specified condition in a program. By using &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"VB.net Loops &#8211; For Each, Do While, While End, For Next\" class=\"read-more button\" href=\"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-loops\/#more-65157\" aria-label=\"Read more about VB.net Loops &#8211; For Each, Do While, While End, For Next\">Read more<\/a><\/p>\n","protected":false},"author":1767,"featured_media":65154,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[305,82197,82204,82201,82202,82199,82200,82198,82203,18969],"class_list":["post-65157","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-visual-basic-tutorial","tag-do-while-loop-in-vb-net","tag-factorial-program-in-vb-net-using-for-loop","tag-for-each-loop-in-vb-net","tag-for-loop-syntax-in-vb-net","tag-looping-statement-in-vb-net","tag-looping-statements-in-vb-net-with-examples","tag-vb-net-do-loop","tag-vb-net-for-loop-array","tag-vb-net-while-loop","tag-vb-net-for-loop","resize-featured-image"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>VB.net Loops - For Each, Do While, While End, For Next<\/title>\n<meta name=\"description\" content=\"Learn on How To use the Different Types of Loops in VB.net and its functions. Check Here the different type of loops in vb.net with example.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-loops\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"VB.net Loops - For Each, Do While, While End, For Next\" \/>\n<meta property=\"og:description\" content=\"Learn on How To use the Different Types of Loops in VB.net and its functions. Check Here the different type of loops in vb.net with example.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-loops\/\" \/>\n<meta property=\"og:site_name\" content=\"Itsourcecode.com\" \/>\n<meta property=\"article:published_time\" content=\"2022-06-24T10:01:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-21T05:44:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Loops-Tutorial-in-VB-NET.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1460\" \/>\n\t<meta property=\"og:image:height\" content=\"900\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"angel jude suarez\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"angel jude suarez\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/tutorials\\\/visual-basic-tutorial\\\/vb-net-loops\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/tutorials\\\/visual-basic-tutorial\\\/vb-net-loops\\\/\"},\"author\":{\"name\":\"angel jude suarez\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#\\\/schema\\\/person\\\/dafb6a91b43e60537c56e3e1d227d460\"},\"headline\":\"VB.net Loops &#8211; For Each, Do While, While End, For Next\",\"datePublished\":\"2022-06-24T10:01:53+00:00\",\"dateModified\":\"2023-11-21T05:44:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/tutorials\\\/visual-basic-tutorial\\\/vb-net-loops\\\/\"},\"wordCount\":1921,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#\\\/schema\\\/person\\\/ad9e0497e03b85a9ca299d935298f5dc\"},\"image\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/tutorials\\\/visual-basic-tutorial\\\/vb-net-loops\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/Loops-Tutorial-in-VB-NET.png\",\"keywords\":[\"Do while loop in vb.net\",\"factorial program in vb net using for loop\",\"for each loop in vb net\",\"for loop syntax in vb net\",\"looping statement in vb net\",\"looping statements in vb net with examples\",\"vb net do loop\",\"vb net for loop array\",\"vb net while loop\",\"vb.net for loop\"],\"articleSection\":[\"VB.NET Tutorial\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/itsourcecode.com\\\/tutorials\\\/visual-basic-tutorial\\\/vb-net-loops\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/tutorials\\\/visual-basic-tutorial\\\/vb-net-loops\\\/\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/tutorials\\\/visual-basic-tutorial\\\/vb-net-loops\\\/\",\"name\":\"VB.net Loops - For Each, Do While, While End, For Next\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/tutorials\\\/visual-basic-tutorial\\\/vb-net-loops\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/tutorials\\\/visual-basic-tutorial\\\/vb-net-loops\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/Loops-Tutorial-in-VB-NET.png\",\"datePublished\":\"2022-06-24T10:01:53+00:00\",\"dateModified\":\"2023-11-21T05:44:31+00:00\",\"description\":\"Learn on How To use the Different Types of Loops in VB.net and its functions. Check Here the different type of loops in vb.net with example.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/tutorials\\\/visual-basic-tutorial\\\/vb-net-loops\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/itsourcecode.com\\\/tutorials\\\/visual-basic-tutorial\\\/vb-net-loops\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/tutorials\\\/visual-basic-tutorial\\\/vb-net-loops\\\/#primaryimage\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/Loops-Tutorial-in-VB-NET.png\",\"contentUrl\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/Loops-Tutorial-in-VB-NET.png\",\"width\":1460,\"height\":900,\"caption\":\"Loops Tutorial in VB NET\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/tutorials\\\/visual-basic-tutorial\\\/vb-net-loops\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/itsourcecode.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"VB.net Loops &#8211; For Each, Do While, While End, For Next\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#website\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/\",\"name\":\"Itsourcecode.com\",\"description\":\"Partner In Your Coding Journey!\",\"publisher\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#\\\/schema\\\/person\\\/ad9e0497e03b85a9ca299d935298f5dc\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/itsourcecode.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#\\\/schema\\\/person\\\/ad9e0497e03b85a9ca299d935298f5dc\",\"name\":\"itsourcecode\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/IT-SOURCECODE_ICON-07.jpg\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/IT-SOURCECODE_ICON-07.jpg\",\"contentUrl\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/IT-SOURCECODE_ICON-07.jpg\",\"width\":409,\"height\":409,\"caption\":\"itsourcecode\"},\"logo\":{\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/IT-SOURCECODE_ICON-07.jpg\"},\"description\":\"Hello Itsourcecoders, welcome to itsourcecode.com. I'm Joken Villanueva, MIT a passionate Blogger, Programmer and a Hobbyist. I started Itsourcecode because I wanted to give back and Share all the learnings and knowledge I've learned in my career and I believe through this website I would be able to help and assist those newbie programmers in enhancing their skills from different programming languages. So let us all help each other by sharing our ideas!\",\"sameAs\":[\"https:\\\/\\\/itsourcecode.com\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/#\\\/schema\\\/person\\\/dafb6a91b43e60537c56e3e1d227d460\",\"name\":\"angel jude suarez\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/litespeed\\\/avatar\\\/49f87b924bdd4e5fcbc3635ed3f7af29.jpg?ver=1776429718\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/litespeed\\\/avatar\\\/49f87b924bdd4e5fcbc3635ed3f7af29.jpg?ver=1776429718\",\"contentUrl\":\"https:\\\/\\\/itsourcecode.com\\\/wp-content\\\/litespeed\\\/avatar\\\/49f87b924bdd4e5fcbc3635ed3f7af29.jpg?ver=1776429718\",\"caption\":\"angel jude suarez\"},\"description\":\"Hello programmers, I'm Angel Jude Reyes Suarez, a student and a programmer of different programming languages like Python, Java, JavaScript, PHP, C, C++, Vb.net, and MySQL. and I have also knowledge in developing system or websites from Front-End to Back-End. and also a writer of itsourcecode.com.\",\"url\":\"https:\\\/\\\/itsourcecode.com\\\/author\\\/angeljudesuarez\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"VB.net Loops - For Each, Do While, While End, For Next","description":"Learn on How To use the Different Types of Loops in VB.net and its functions. Check Here the different type of loops in vb.net with example.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-loops\/","og_locale":"en_US","og_type":"article","og_title":"VB.net Loops - For Each, Do While, While End, For Next","og_description":"Learn on How To use the Different Types of Loops in VB.net and its functions. Check Here the different type of loops in vb.net with example.","og_url":"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-loops\/","og_site_name":"Itsourcecode.com","article_published_time":"2022-06-24T10:01:53+00:00","article_modified_time":"2023-11-21T05:44:31+00:00","og_image":[{"width":1460,"height":900,"url":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Loops-Tutorial-in-VB-NET.png","type":"image\/png"}],"author":"angel jude suarez","twitter_card":"summary_large_image","twitter_misc":{"Written by":"angel jude suarez","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-loops\/#article","isPartOf":{"@id":"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-loops\/"},"author":{"name":"angel jude suarez","@id":"https:\/\/itsourcecode.com\/#\/schema\/person\/dafb6a91b43e60537c56e3e1d227d460"},"headline":"VB.net Loops &#8211; For Each, Do While, While End, For Next","datePublished":"2022-06-24T10:01:53+00:00","dateModified":"2023-11-21T05:44:31+00:00","mainEntityOfPage":{"@id":"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-loops\/"},"wordCount":1921,"commentCount":0,"publisher":{"@id":"https:\/\/itsourcecode.com\/#\/schema\/person\/ad9e0497e03b85a9ca299d935298f5dc"},"image":{"@id":"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-loops\/#primaryimage"},"thumbnailUrl":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Loops-Tutorial-in-VB-NET.png","keywords":["Do while loop in vb.net","factorial program in vb net using for loop","for each loop in vb net","for loop syntax in vb net","looping statement in vb net","looping statements in vb net with examples","vb net do loop","vb net for loop array","vb net while loop","vb.net for loop"],"articleSection":["VB.NET Tutorial"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-loops\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-loops\/","url":"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-loops\/","name":"VB.net Loops - For Each, Do While, While End, For Next","isPartOf":{"@id":"https:\/\/itsourcecode.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-loops\/#primaryimage"},"image":{"@id":"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-loops\/#primaryimage"},"thumbnailUrl":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Loops-Tutorial-in-VB-NET.png","datePublished":"2022-06-24T10:01:53+00:00","dateModified":"2023-11-21T05:44:31+00:00","description":"Learn on How To use the Different Types of Loops in VB.net and its functions. Check Here the different type of loops in vb.net with example.","breadcrumb":{"@id":"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-loops\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-loops\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-loops\/#primaryimage","url":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Loops-Tutorial-in-VB-NET.png","contentUrl":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2022\/06\/Loops-Tutorial-in-VB-NET.png","width":1460,"height":900,"caption":"Loops Tutorial in VB NET"},{"@type":"BreadcrumbList","@id":"https:\/\/itsourcecode.com\/tutorials\/visual-basic-tutorial\/vb-net-loops\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/itsourcecode.com\/"},{"@type":"ListItem","position":2,"name":"VB.net Loops &#8211; For Each, Do While, While End, For Next"}]},{"@type":"WebSite","@id":"https:\/\/itsourcecode.com\/#website","url":"https:\/\/itsourcecode.com\/","name":"Itsourcecode.com","description":"Partner In Your Coding Journey!","publisher":{"@id":"https:\/\/itsourcecode.com\/#\/schema\/person\/ad9e0497e03b85a9ca299d935298f5dc"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/itsourcecode.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/itsourcecode.com\/#\/schema\/person\/ad9e0497e03b85a9ca299d935298f5dc","name":"itsourcecode","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/01\/IT-SOURCECODE_ICON-07.jpg","url":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/01\/IT-SOURCECODE_ICON-07.jpg","contentUrl":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/01\/IT-SOURCECODE_ICON-07.jpg","width":409,"height":409,"caption":"itsourcecode"},"logo":{"@id":"https:\/\/itsourcecode.com\/wp-content\/uploads\/2021\/01\/IT-SOURCECODE_ICON-07.jpg"},"description":"Hello Itsourcecoders, welcome to itsourcecode.com. I'm Joken Villanueva, MIT a passionate Blogger, Programmer and a Hobbyist. I started Itsourcecode because I wanted to give back and Share all the learnings and knowledge I've learned in my career and I believe through this website I would be able to help and assist those newbie programmers in enhancing their skills from different programming languages. So let us all help each other by sharing our ideas!","sameAs":["https:\/\/itsourcecode.com\/"]},{"@type":"Person","@id":"https:\/\/itsourcecode.com\/#\/schema\/person\/dafb6a91b43e60537c56e3e1d227d460","name":"angel jude suarez","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/itsourcecode.com\/wp-content\/litespeed\/avatar\/49f87b924bdd4e5fcbc3635ed3f7af29.jpg?ver=1776429718","url":"https:\/\/itsourcecode.com\/wp-content\/litespeed\/avatar\/49f87b924bdd4e5fcbc3635ed3f7af29.jpg?ver=1776429718","contentUrl":"https:\/\/itsourcecode.com\/wp-content\/litespeed\/avatar\/49f87b924bdd4e5fcbc3635ed3f7af29.jpg?ver=1776429718","caption":"angel jude suarez"},"description":"Hello programmers, I'm Angel Jude Reyes Suarez, a student and a programmer of different programming languages like Python, Java, JavaScript, PHP, C, C++, Vb.net, and MySQL. and I have also knowledge in developing system or websites from Front-End to Back-End. and also a writer of itsourcecode.com.","url":"https:\/\/itsourcecode.com\/author\/angeljudesuarez\/"}]}},"_links":{"self":[{"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/posts\/65157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/users\/1767"}],"replies":[{"embeddable":true,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/comments?post=65157"}],"version-history":[{"count":71,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/posts\/65157\/revisions"}],"predecessor-version":[{"id":120497,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/posts\/65157\/revisions\/120497"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/media\/65154"}],"wp:attachment":[{"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/media?parent=65157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/categories?post=65157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itsourcecode.com\/wp-json\/wp\/v2\/tags?post=65157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}