Exit a Do While Loop : Exit « Language Basics « VB.Net

Exit a Do While Loop

Exit a Do While Loop
Imports System

Public Class MainClass
    Shared Sub Main()

        'Declare variable
        Dim intCount As Integer = 0

        'Process the loop
        Do While intCount < 10

            'Add the item to the list

            'Increment intCount by 1
            intCount += 1

            'Should you quit
            If intCount = 3 Then
                Exit Do
            End If

    End Sub
End Class


Related examples in the same category

1.Exit an ApplicationExit an Application
2.Exit a LoopExit a Loop