Repeating a statement until a condition becomes true, Visual Basic Programming

You can employ until keyword in two ways to verify a condition in a Do...Loop statement. You can verify the condition before you enter the loop (as illustrated in the following ChkFirstUntil instance), or you can verified it after the loop has run at least once (as illustrated in the ChkLastUntil instance). As long as the condition is False, the loop will be continues.

Sub ChkFirstUntil()

Dim counter, myNum counter = 0

myNum = 20

Do Until myNum = 10 myNum = myNum - 1 counter = counter + 1

Loop

MsgBox "The loop made" & counter & "repetitions." End Sub

Sub ChkLastUntil()

Dim counter, myNum counter = 0

myNum = 1

Do

myNum = myNum + 1 counter = counter + 1

Loop Until myNum = 10

MsgBox "The loop made " & counter & " repetitions." End Sub

Posted Date: 4/18/2013 5:50:48 AM | Location : United States







Related Discussions:- Repeating a statement until a condition becomes true, Assignment Help, Ask Question on Repeating a statement until a condition becomes true, Get Answer, Expert's Help, Repeating a statement until a condition becomes true Discussions

Write discussion on Repeating a statement until a condition becomes true
Your posts are moderated
Related Questions
( Wage Calculator with Tax Calculations) Develop an application that calculates an employee’s earnings, as shown in Fig. 4.23. The user should provide the hourly wage and number of

CLASS WIZARD The Class wizard shown in figure is a tool to handle the message handlers for objects, to define the member variables. Figure: Class Wizard

Fixed length strings: The Fixed length strings are declared by identifying the size of the string. For illustration to give a length of 20 for the string place, the declarati

ToolTip: The ToolTip property is used to flash a message regarding a control object when the mouse pointer moves over that object for a couple of seconds. Pick a control and c

Write a program to print a digital clock which displays the time for 2 hours . ..

Displaying a file With Scrolling: To display a file with the scrolling option allows the steps as shown below: 1. Generate a SDI application. 2. In the Step 6 of the App

APPWIZARD   The Appwizard is a tool used for creating a project. It follows a series of steps to create a project. Steps Involved in Creating A Project: Step 1: Fr

Scenario GetLoan is a new company that will provide a loan of money to individual members of the public.   There are two types of loan to be offered: Secured Loan wher

A Project to Display a Database: 1. Suppose that there are 5 fields describing a customer. Id, address, name, city & state. 2. Put 5 text boxes on the form to exhibit the r

Files in a SDI and MDI Application: Both the SDI and MDI projects have 4 implementation files (.cpp extension). These are the files equivalent to the Document Class, View Clas