vb.net 'break' 的等效 VB 关键字

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5759/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 13:48:04  来源:igfitidea点击:

Equivalent VB keyword for 'break'

vb.netloopsvb6exit

提问by Tyronomo

I just moved over to the Visual Basic team here at work.

我刚搬到这里工作的 Visual Basic 团队。

What is the equivalent keyword to breakin Visual Basic, that is, to exit a loop early but not the method?

breakVisual Basic 中的等效关键字是什么,即提前退出循环但不退出方法?

回答by John

In both Visual Basic 6.0 and VB.NETyou would use:

在 Visual Basic 6.0 和VB.NET 中,您将使用:

  • Exit Forto break from For loop
  • Wendto break from While loop
  • Exit Doto break from Do loop
  • Exit For打破 For 循环
  • Wend打破 While 循环
  • Exit Do打破 Do 循环

depending on the loop type. See Exit Statementsfor more details.

取决于循环类型。有关更多详细信息,请参阅退出声明

回答by Ayman El Temsahi

In case you're inside a Sub of Function and you want to exit it, you can use :

如果您在 Function 的 Sub 中并且想要退出它,您可以使用:

Exit Sub

or

或者

Exit Function 

回答by Eric Haskins

Exit[construct], and intelisense will tell you which one(s) are valid in a particular place.

Exit[构造],智能感知会告诉你哪些(哪些)在特定的地方是有效的。