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
Creation of the Menu in VB 1. Initiate a new project by choosing a file and then new project. 2. Now select the Standard EXE as the Project type. 3. Build the Form1 activ

Create a VB calculator application that appears as in the screen shots below. The user enters numbers in the textboxes labelled Number 1 and Number 2. When a calculati

A variable is convenient placeholder which refers to a computer memory location where you can store program information which may change when your script is running. For instance,

DIALOG   The dialog is a window which contains controls. The Dialog boxes are the form of input and output. The control can be placed on the dialog box for communicating. If y

US WordPress Expert We are functioning on a software application based on WordPress (BuddyPress + Event Manager). Everything as far as functionality is done. Utmost of the styli

THREE MODELS FOR USER INTERFACE DESIGN   The 3 models for the user interface design are the implementation model, mental model &the manifest model. The Implementation Mod

Use of WM_SIZE Message: Whenever the WM_SIZE message is handled and the graphical objects on the output window will also change consequently to the output window. The functi

Objective: To develop an Application (Excel + VBA) that determines the optimal inventory policy under an All-Units Discount scheme. APPLICATION CHARACTERISTICS Consider the

INTRODUCTION to VISUAL C++ PROGRAMMING This section introduces you to develop the applications using VC++. The Single document interface (SDI), multiple document interface (MDI

Assume that s is a string variable that is supposed to contain a value to be converted to integer. Write a fragment of code that converts the value to integer variable and displ