17. Do Until

In this tutorial, we cover the third and last loop, the Do Until loop. All of the loops are similar, but the Do Until loop will execute a piece of code until a condition is true. In this video you will see how to use do until.

Code

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim num As Integer = 1

        Do Until num = 5
            MessageBox.Show("The value of num is: " & num)
            num = num + 1
        Loop

    End Sub

End Class