vbnet
  1. vbnet-continue-statement

Control Statements in VB.NET: Continue Statement

In VB.NET, the Continue statement is a control statement that is used to skip over an iteration of a loop. In this page, we will discuss the syntax, example, output, explanation, use, important points, and summary of the Continue statement.

Syntax

The syntax of the Continue statement is simple. It is used within a loop to skip over an iteration of the loop. Here's the syntax:

Continue

Example

Here's an example of how the Continue statement can be used inside a For...Next loop in VB.NET:

For i As Integer = 1 To 10
    If i = 5 Then
        Continue For
    End If
    Console.WriteLine(i)
Next

In this example, the loop iterates from 1 to 10. If the value of i is 5, then the Continue statement is used to skip over the current iteration of the loop. As a result, the value 5 is not printed to the console.

Output

The output of the above example would be:

1
2
3
4
6
7
8
9
10

Explanation

The Continue statement is used to skip over an iteration of a loop. When the loop encounters a Continue statement, it immediately jumps to the next iteration of the loop, skipping the remaining code in the current iteration.

In the example above, the value of i is checked at the beginning of each iteration. If the value of i is 5, then a Continue For statement is executed, which skips the current iteration and jumps immediately to the next iteration.

Use

The Continue statement is especially useful in loops where certain iterations need to be skipped. It can be used in any type of loop statement, including For...Next loops, While loops, and Do...Loop loops.

Important Points

  • The Continue statement is used to skip over an iteration of a loop.
  • It can be used in any type of loop statement.
  • When the loop encounters a Continue statement, it immediately jumps to the next iteration of the loop, skipping the remaining code in the current iteration.

Summary

In this page, we discussed the Continue statement, which is used to skip over an iteration of a loop in VB.NET. We covered the syntax, example, output, explanation, use, important points, and summary of the Continue statement. The Continue statement is a useful tool for controlling the flow of a loop, especially in situations where certain iterations need to be skipped.

Published on: