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


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

Sub ChkLastUntil()

Dim counter, myNum counter = 0

myNum = 1


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

Your posts are moderated
Related Questions
ODBC   The ODBC gives an API which distinguishes the data base vendors implementation via the ODBC drivers specific to a DBMS. The program will use the API to call the ODBC dr

While a run-time error takes place, the properties of the Err object are filled with information which uniquely identifies the error & information which can be used to handle it. I

Visual Interface  Based On Visual Patterns: The visual user interface should create recognizable patterns and text will be used for differentiating the objects with similar pa

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

VBScript Operators VBScript contain a full range of operators, including comparison operators, arithmetic operators, concatenation operators, and logical operators.

FILES IN A VB PROJECT The project file has the.vbp extension. The form in which we draw has the .frm extension; .mod denotes the module file; .cls denotes the class file; .res

Depreciation to a Salvage Value of 0.   For tax purposes an item may be depreciated over a period of several years, n. With the straight-line method of depreciation, each year th

The Select Case structure provides an option to If...Then...Else If for selectively executing one block of statements from amongst multiple blocks of statements. Any Select Case st