Do Loop in

By: Ramlak Emailed: 1747 times Printed: 2431 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 )
Your first VB.NET Crystal Reports - A step by step guide
Visual Basic Statements
How to export from DataGridView to excel using
DataRow Class in
How to Open and Edit Cells in an Excel 2007 file in VB.NET
How to export from database to excel using
Using Resume Next and Resume Line in
What's New in VB .NET? A comparison of VB vs
Data types in
Arrays and Dynamic Arrays in
Do Loop in
String endswith, concat in
How to read URL Content through code
Client Socket Program sample in
Chat Server in
Most Emailed Articles (in
OleDbConnection class in
String Insert, index off & format in
Data types in
Arrays and Dynamic Arrays in
Handling Strings in
Using Excel 2007 Chart Picture Box
The Option and Imports Statements in VB .NET
Do Loop in
Stack data structure in
String equals, Copy to & Copy to in
String endswith, concat in
Excel 2007 Data Validation Input Message using
Read Data from Excel using OLEDB in VB.NET 2005
How to export from DataGridView to excel using
Multi Threaded Server Socket Programming in