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 Exit statement in VBS

2025-02-27 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 Exit 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!

Exit the Do...Loop, For...Next, Function, or Sub code block.

Exit Do

Exit For

Exit Function

Exit Property

Exit Sub

The syntax of an Exit statement has the following forms:

Statement description Exit Do provides a way to exit a Do...Loop statement. Can only be used in Do...Loop statements. Exit Do transfers control to the statement after the Loop statement. When used in nested Do...Loop statements, Exit Do transfers control to the upper level of the nested loop where the loop is located. Exit For provides a way to exit the For loop. Can only be used in For...Next or For Each...Next loops. Exit For transfers control to the statement after Next. When used in a nested For loop, the Exit For transfers control to the upper level of the nested loop where the loop is located. Exit Function immediately exits the Function process from where it appears. Continue to execute the statement that follows the statement that called Function. Exit Property immediately exits from the Property process it is in. Continue with the following statement that calls the Property procedure. Exit Sub immediately exits the Sub procedure from where it appears and continues to execute the statement that follows the statement that called Sub.

The following example illustrates how to use the Exit statement:

Sub RandomLoop Dim I, MyNum Do 'sets an endless loop. For I = 1 To 1000 'cycle 1000 times. MyNum = Int (Rnd * 100) 'generates a random number. Select Case MyNum'to find the value of the random number. Case 17: MsgBox "Case 17" Exit For'if it is 17, exit For...Next. Case 29: MsgBox "Case 29" Exit Do'if it is 29, exit Do...Loop. Case 54: MsgBox "Case 54" Exit Sub'if 54, exit the Sub process. This is the end of End Select Next LoopEnd Sub's "usage of Exit sentences 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