Do Loop in

By: Ramlak Emailed: 1646 times Printed: 2120 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

The Do loop keeps executing its enclosed statements while or until (depending on which keyword you use, While or Until) condition is true. You can also terminate a Do loop at any time with an Exit Do statement. The Do loop has two versions; you can either evaluate a condition at the beginning:

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

or at the end:

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

Here's an example where the code keeps displaying the message "What should I do?" until the user types "Stop" (note that I'm using UCase to uppercase what the user types and comparing it to "STOP" to let them use any combination of case when they type "Stop"):

Module Module1
    Sub Main()
        Dim strInput As String
        Do Until UCase(strInput) = "STOP"
            System.Console.WriteLine("What should I do?")
            strInput = System.Console.ReadLine()
    End Sub
End Module

The second form of the Do loop insures that the body of the loop is executed at least once. Home | All Tutorials | Latest Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.

Bookmark and Share


Be the first one to add a comment

Your name (required):

Your email(required, will not be shown to the public):

Your sites URL (optional):

Your comments:

More Tutorials by Ramlak
While Loop in
For Each…Next Loop in
For Loop in
Do Loop in
Setting Up SSL on Tomcat
Unicode and UTF-8 in C
Sample program to demonstrate the use of ActionListener HTTPS hostname wrong: should be PKIX path building failed: unable to find valid certification path to requested target Connection refused: connect
'LINK.EXE' is not recognized as an internal or ext
Using Transactions in JDBC
What is the ACID principal?
How connection pooling works in Java and JDBC
A simple JDBC application sample code

More Tutorials in
Scope in
Unstructured Exception Handling in
Structured Exception Handling in
Creating Sub Procedures in
Creating Functions in
Passing a Variable Number of Arguments to Procedures in
Specifying Optional Arguments with default values in Procedures in
Preserving a Variable's Values between Procedure Calls in
Procedure Delegates in
Properties in
Understanding Scope in
Using Resume Next and Resume Line in
Using On Error GoTo 0 in
Getting an Exception's Number and Description in
Raising an Exception Intentionally in

More Latest News
Most Viewed Articles (in )
For Loop in
For Each…Next Loop in
Read Data from Excel using OLEDB in VB.NET 2005
Insert cell data in an Excel file using OLEDB in
Client Socket Program sample in
OleDbDataAdapter class in
The For Loop in
What is .NET Framework and the Common Language Runtime?
Assemblies, Solutions and Projects in VB .NET
Operators in
If…Else Statements in
Do Loop in
Queue data structure in
How to Open and Edit Cells in an Excel 2007 file in VB.NET
Format Excel 2007 Page in VB.NET
Most Emailed Articles (in
How to Open and Edit Cells in an Excel 2007 file in VB.NET
Format Excel 2007 Page in VB.NET
Nested If and Single line if statement
Multi threaded Socket Programming in
Using Select Case in
How to export from DataGridView to excel using
Structured Exception Handling in
Properties in
To read the entire worksheet in an Excel workbook through Code
How to create an XML file in
A tutorial on Chat Server and Chat Client in
Changes in Controls from VB6 to
“Using If with And” and Comparing two integers using If
For Loop in
Stack data structure in