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

sir , i need visual basic form design & coding for Reynolds number & type of flow .

how to make logic of o program and how to use loop

Problem 1. Describe the importance and usage of .net framework in visual Studio 2. Write a program to sort and display an array of integers in ascending order using the conc

DYNAMIC LINK LIBRARY - DLL   The DLL are files which can be called when required by the other program that is running in the computer. The DLL files which support the specific

Goal Create a Visual Basic that allows a user to play a variation of Hangman. User Inputs • The user types a letter into the textbox. Functional Items 1. Read a series

You can exit a Do...Loop using the Exit Do statement. Since usually you desire to exit only in certain situations, such as to ignore an endless loop, you should employ the Exit Do

MENUS AND TOOL BARS   The Menu options can be checked, enabled, disabled, and popped up on an object. The Menu Object: The Menu control is used to generate a menu in

A variation on the If...Then...Else statement lets you to choose from various alternatives. By adding up Else If clauses expands the functionality of the If...Then...Else statement

Data types: The New data types were defined by using the typedef or #define statements. This was to allow the transition from 16 bit to 32 bit system. Some of the fresh data t