Do Until Loop in Visual Basic .NET

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

This lesson describes how to use Do Until loop in Visual Basic .NET

One of the Do Loop statements variations is the Do Until and it keeps going until something happens (until a condition is true).

Its syntax is as follows:

Do {Until} condition
	[Exit Do]

Meaning the Until loop keeps running until the condition is satisfied. In this type of loop, there is not a control variable in itself so you have to keep track of the current position of the loop.

Dim array() As Integer = {1, 3, 5, 7, 10, 20, 50}
Dim counter As Integer = array.GetUpperBound(0) + 1
Do Until counter > 0
	counter -= 1
	'print the array elements
' Visual Basic won't execute the statements because counter is already greater than 0

Previous Lesson | Next Lesson

Share This

Home | About | Contact | Privacy Policy

Copyright 2017 - All Rights Reserved.