Javatpoint Logo
Javatpoint Logo

VB.NET Continue Statement

In VB.NET, the continue statement is used to skip the particular iteration of the loop and continue with the next iteration. Generally, the continue Statement is written inside the body of the For, While and Do While loop with a condition. In the previous section, we learned about the Exit Statement. The main difference between the Exit and a Continue Statement is that the Exit Statement is used to exit or terminate the loop's execution process. In contrast, the Continue Statement is used to Skip the particular iteration and continue with the next iteration without ending the loop.

Syntax:

Flow Diagram of Continue Statement

Following is the pictorial representation of the Continue Statement in VB.NET programming language.

VB.NET Continue Statement

In the above diagram, a Continue Statement is placed inside the loop to skip a particular statement or iteration. Generally, a continue statement is used with a condition. If the condition is true, it skips the particular iteration and immediately transfers the control to the beginning of the loop for the execution of the next iteration.

Now we will see how to use the Continue statement in the loop to skip the execution of the code and send the control to the beginning of the loop to execute further statements in the VB.NET programming language.

Use of Continue statement in While End loop

Example 1: Write a simple program to use the Continue Statement in While End loop.

Continue_While.vb

Output:

VB.NET Continue Statement

In the above program, the While loop is continuously executed, their body until the given condition ( i < 20) is met. But when the value of i is equal to 15, the Continue statement is encountered. It skips the current execution and transfers the control to the beginning of the loop to display the next iteration.

Use of Continue statement in For Next loop

Example 2: Write a simple program to print the number from 10 to 1 with Continue Statement in For Next loop.

Continue_For.vb

Output:

VB.NET Continue Statement

In the above program, the For loop is continuously decremented their body until the variable i is 1. But when the value of i is equal to 5, the Continue Statement is encountered. Then it skips the current execution and transfers control to the beginning of the loop to display the next iteration.

Use of Continue statement in Do While loop

Example 3: Write a simple program to Understand the use of Continue Statement in Do While loop.

Continue_Do_While.vb

Output:

VB.NET Continue Statement

In the above program, the Do loop is continuously executed their body until the given condition ( i < 20) is met. But when the value of i is equal to 15, the Continue Statement is encountered. It skips the current execution and transfers the control to the beginning of the loop to display the next iteration.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA