Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

VB.Net - Loop


May 13, 2021 vb.net


Table of contents


There may be a situation when you need to execute a piece of code several times.

In general, statements are executed sequentially: the first statement in a function executes first, then the second statement, and so on.

Programming languages provide a variety of control structures that allow for more complex execution paths.

Loop statements allow us to execute a statement or set of statements multiple times, as is the general form of circular statements in most programming languages:


VB.Net - Loop

VB.Net provides the following types of loops to handle loop requirements. Click the link below to check its details.

Cycle type describe

Do Loop

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.
It repeatedly included the statement block inner Boolean conditions True Or until the conditions become True .It can be used at any time Exit Do The statement is terminated.

For...Next

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.
It repeats a group of statements that specify the number of times, and the loop index calculates the number of cyclic hands during the loop execution.

For Each...Next

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.
It repeats a group of statements for each element in the collection.This loop is used to access and operate all elements in an array or VB.NET collection.

While... End While

It executes a series of statements as long as a given condition is True.
As long as a given condition is True It performs a series of statements.

With... End With

It is not exactly a looping construct. It executes a series of statements that repeatedly refer to a single object or structure.
It is not a loop structure.It performs a series of statements that repeatedly reference a single object or structure.

Nested loops

You can use one or more loops inside any another While, For or Do loop.
You can be in any other While For or Do One or more cycles are used in the cycle.

Loop control statement:

The loop control statement changes execution from its normal sequence. When execution leaves the scope, all automatic objects created in that scope are destroyed.

VB.Net provides the following control statements. Click the link below to check its details.

Control statement describe

Exit statement

Terminates the loop or select case statement and transfers execution to the statement immediately following the loop or select case.

Terminate loops or select the case and will perform the statements that perform the transition to a loop or select the size.

Continue statement

Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.
It causes the loop to skip the rest of its own, and immediately retest its status before repeating.

GoTo statement

Transfers control to the labeled statement. Though it is not advised to use GoTo statement in your program.

Transfer control to the tag-based statement.Although it is not recommended to use in the program GoTo Scriptures.