Do While Loop in Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

This lesson describes how to use Do While loops in Visual Basic .NET

One of the Do Loop statements variations is the Do While and it executes as long as a condition is true (while a particular condition is true).

Its syntax is as follows:

Do {While} condition
[Exit Do]

This While loop keeps running as long as the expression is True. As soon as the expression becomes False, it stops.

Dim array() As Integer = {1, 3, 5, 7, 10, 20, 50}
Dim counter As Integer = array.GetUpperBound(0) + 1
Do While counter > 0
    counter -= 1
    'print the array elements
 ' this loop prints out all the array elements

Share This

Home | About | Contact | Privacy Policy

Copyright 2018 - All Rights Reserved.