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






Your posts are moderated
Related Questions


ILLUSTRATION OF CCOLORDIALOG The constructor of the CColorDialog takes the initial parameter as the default color and the next parameter specifies how much the dialog is displa

i have a database i want mange it network and i want write it with vb.net so how i can do this

The objective of this unit is to describe the basics of VBScript. After completing this unit, you will be capable to write code for Web pages via VBScript. You will be able to unde

write a detailed account on ADO.net architecture.

I need assistance with writing the Tryparse I have 98% of the assignment done.

FILE SYSTEM CONTROLS There are 3 file system controls as shown in figure. The drive list box, directory list box & the file list box. The drive list box control is used to exhi


INTRODUCTION TO DATABASE APPLICATIONS   In this section, we define a dialog and tab order that is the order in which the controls will be navigated during the execution. The D