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
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

Events: The Controls are placed on a form and then to make them functional an "event procedure" is related with the control object. An event process is what happens in respons


INTRINSIC CONTROLS   The Intrinsic controls are the built-in controls. Few of the controls are Combo box, Check box, Command Button, Label etc. The controls have properties re

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

Dialog Based Application: The application which app wizard generates is based on the dialog template resource.


SDK PROGRAMMING The SDK programming is a developing Win 32 based programs using the Win 32 API that directly interact with the hardware. Therefore the execution of the SDK prog

to dial a person''s 10 digit number and assign it to their name

WINDOWS PROGRAMMING The Windows programming is a developing application using the C and the native Win32 application interface (API) or C++ and the class libraries like Microso