Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The usage of Do...Loop statement in VBS

2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "the use of Do...Loop sentences in VBS". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

A statement block is repeated when the condition is True or before 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]

Parameter condition

A numeric or string expression whose value is True or False. If condition is Null, condition is treated as False.

Statements

One or more commands that are repeated when condition is True.

Description

Exit Do can only be used in Do...Loop control statements, providing another way to exit Do...Loop. You can place any Exit Do anywhere in the Do...Loop statement. Exit Do is usually used with conditional judgment statements, such as If...Then, to pass control to the statement immediately following the Loop statement.

When used in a nested Do...Loop, Exit Do passes control to the upper layer of the nested loop in which it resides.

The following example illustrates how to use the Do...Loop statement:

Do Until DefResp = vbNo MyNum = Int (6 * Rnd + 1) 'produces a random number between 1 and 6. DefResp = MsgBox (MyNum & "do you want another number?" , vbYesNo) LoopDim Check, CounterCheck = True: Counter = 0 'initialize the variable. Do 'outer loop. Do While Counter < 20 'inner loop. Counter = Counter + 1 'increments the counter. If Counter = 10 Then'if the condition is True... Check = False 'sets the flag value to False. Exit Do 'terminates the inner loop. End If LoopLoop Until Check = False 'immediately terminates the outer loop. This is the end of the introduction to "the use of Do...Loop statements in VBS". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report