Do...Loop Statement


Do   [{While|Until} condition]
        [statements]
       [Exit Do]
       [statements]
Loop

Do
       [statements]
       [Exit Do]
       [statements]
Loop [{While|Until} condition]

Repeats a group of  statements while a condition is true or until a condition is met.

Example:

    Sub Main()

        Dim Value, Msg   ' Declare variables.

        Do

            Value = InputBox("Enter a value from 5 to 10.")

            If Value >= 5 And Value <= 10 Then

                Exit Do   ' Exit Do...Loop.

            Else

                Beep   ' Beep if not in range.

            End If

        Loop

    End Sub


Related Topics:

While...Wend Statement