Visual Basic Exit 语句
Exit 语句将终止循环过程,并执行循环体外的代码。
如果使用嵌套循环(即在一个循环内部有另外一个循环),则 Exit 语句将停止最内层循环的执行,并开始执行代码块之后的下一行代码。
语法
Exit 语句的语法是:
流程图

实例
Module loopsSub Main()' local variable definitionDim a As Integer = 10' while loop execution 'While (a < 20)Console.WriteLine("value of a: {0}", a)a = a + 1If (a > 15) Then'terminate the loop using exit statementExit WhileEnd IfEnd WhileConsole.ReadLine()End SubEnd Module
结果如下:
value of a: 10value of a: 11value of a: 12value of a: 13value of a: 14value of a: 15