VBS TUTORIAL: VBScript statement-do ... Loop Statement _vbs

Source: Internet
Author: User
Tags terminates

Do ... Loop statement

Repeats a block of statements before the condition is true or if the condition becomes true .

Do [{While | Until} condition]
[statements]
[Exit Do]
[statements]
Loop

You can also use the following syntax:

Do
[statements]
[Exit Do]
[statements]
Loop [{While | Until} condition]

Parameters

Condition

A numeric or string expression with a value of True or False. If condition is Null, the condition is treated as False.

Statements

One or more commands that are executed repeatedly when condition is True .

Description

Exit do can only be used in do ... Loop Control statement, provide another exit from do ... The Loop method. Can be in do ... any position in the Loop statement to place any Exitdo. Exit do is usually associated with a conditional judgment statement (for example, if ...). Then ), passing control to the statement immediately following the Loop statement.

When used to nest do ... In Loop ,Exit do passes control to the upper-level nested loop of the loop in which it resides.

The following example shows how to use the Do ... Loop Statement:

Do Until DefResp = vbNo MyNum = Int (6 * Rnd + 1)' Produce 1 To 6 The random number between. DefResp = MsgBox (MyNum & " Want another number?", vbYesNo)LoopDim Check, CounterCheck = True: Counter = 0' Initializes the variable.   do                  '  outer loop.    Do while  Counter <           ' The  inner loop.  Counter = Counter + 1          '  to increase the counter.  if Counter = Then          '  if the condition is  True ...   Check = False             '  sets the flag value to  False .    Exit do               '  terminates the inner loop.  End If   Loop     Loop Until  Check = False           ' The  terminates the outer loop immediately. 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.