Vb.Net-Informations.com

  How to use vb.net While End While loop




   Categories

    HOME
    VB.NET
    CSHARP

 
   














How to use vb.net While End While loop

Whenever you face a situation in programming to repeat a task for several times (more than one times ) or you have to repeat a task till you reach a condition, in these situations you can use loop statements to achieve your desired results.

FOR NEXT Loop, FOR EACH Loop , WHILE Loop and DO WHILE Loop are the Commonly used loops in Visual Basic.NET 2005 ( VB.NET 2005) .

While ..End While

While .. End While Loop execute the code body (the source code within While and End while statements ) until it meets the specified condition.

  
While [condition]
   [loop body]

End While

Condition : The condition set by the user

  
1. counter = 1
2. While (counter <= 10)
3.    Message
4.    counter = counter + 1

5. End While

Line 1: Counter start from 1

Line 2: While loop checking the counter if it is less than or equal to 10

Line 3: Each time the Loop execute the message and show

Line 4: Counter increment the value of 1 each time the loop execute

Line 5: End of the While End While Loop body


         VB.NET Source Code Download           Print Source Code
         How to use vb.net While End While loop - Download
        
VB.Net Tutorial

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, 
	ByVal e As System.EventArgs) Handles Button1.Click
        Dim counter As Integer
        counter = 1
        While (counter <= 10)
            MsgBox("Counter Now is : "  counter)
            counter = counter + 1
        End While
    End Sub
End Class
		

When you execute the program 10 times the message shows with counter and exit from the While .. End While loop.

VB.NET Program Flow Control Related Contents
*     How to use IF ELSE END IF in VB.NET
*     How to use FOR NEXT loop in vb.net
*     How to use FOR EACH loop in VB.NET

VB.Net Related Topics
*     Microsoft .Net Framework Tutorials
*     VB.NET Language Basics Tutorials
*     VB.NET Program Flow Control Tutorials
*     VB.NET Collections Tutorials
*     VB.NET String Tutorials
*     VB.NET Files Tutorials
*     VB.NET Excel 2007 Tutorials
*     VB.NET Crystal Reports Tutorials
*     VB.NET Communications Tutorial
*     VB.NET ADO.NET Tutorial with source code
*     ADO.NET Data Providers help and Tutorial
*     VB.NET ADO.NET Dataset Tutorial
*     ADO.NET DataAdapter and Dataset
*     VB.NET ADO.NET DataView Tutorial
*     VB.NET Remoting Tutorial
*     VB.NET XML Tutorial
Search here for more CSharp Source Code :

  |  Home   |  SiteMap   |  About   |
net-informations.com (C) 2010 All Rights Reserved