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
I have an external application I open from visual studio (excel). I want to reposition where that opens (top, left).. How do I do that?

You can employ For...Next statements to run a block of statements a specific number of times. For loops, employ a counter variable whose value is increased or decreased with each r

A program is needed to assist computing automobile repair bills. The cost of labor is $35 per hour. The costs for parts are subject to a 5% sales tax, which should be added t

I have all my program done except the loan part that I am having a lot of troubles with

STORAGE AND RETRIEVAL SYSTEMS   The storage system is a depository. It is a physical container and gives mechanisms to put in the depository and take them back. The retrieval

What I understand from the assignment is I have to make the VB code in file nu1. xlsm generic, and run several iterations for Kc and Ti to find out the optimal combination which wi

Using Visual Studio 2010 C++ 1) Using Windows Explorer, make a copy of Irvine\examples\Project_sample folder in the folder where you keep your materials for this course.

Develop a web page that is used for accepting information regarding stocks. Make sure the form carry out the possible validations. The simple instance code below merely illustrates

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

Question 1 Design a form based applications using labels, text boxes, and buttons to perform basic arithmetic operations on integers Question 2 Describe the concept of Except