to appropriate label.IfNumber =1ThenGoToLine1ElseGoToLine2 Line1: MyString ="Number equals 1"GoToLastLine' Go to LastLine.Line2:' The following statement never gets executed.MyString ="Number equals 2"LastLine: Debug.Print MyString' Print "Number equals 1" in' the Immediate window.End...
太多GoTo 語句可能會讓程式代碼難以讀取和偵錯。 使用結構化控制項語句(執行...Loop,For...接下來,如果...然後。。。否則,請盡可能選取案例) 。 範例 此範例會使用GoTo 語句來分支至程式內的線條標籤。 VB複製 SubGotoStatementDemo()DimNumber, MyString Number =1' Initialize variable.' Evaluate Number and...
[!注释]GoTo语句太多可能会使代码难以阅读和调试。 使用结构化控制语句(Do...Loop、For...接下来,如果...然后。。。否则,请尽可能选择大小写) 。 示例 此示例使用GoTo语句转到过程内的行标签。 VB复制 SubGotoStatementDemo()DimNumber, MyString Number =1' Initialize variable.' Evaluate Number and branch...
The VBA GoTo statement helps code execution jump to a specific line within the procedure. In simple words, with the goto statement, VBA jumps to a particular line that you specify. For example, if you specify to jump to the second line, GOTO will jump to that line. How to use VBA GoT...
Line2: ' The following statement never gets executed. MyString = "Number equals 2" LastLine: Debug.Print MyString ' Print "Number equals 1" in ' the Immediate window. End Sub 另请参阅数据类型 语句支持和反馈有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有...
GoTo can cause your code to loop back and forth in ways that are difficult to follow. If your code makes use of the GoTo statement the resulting flow is often referred to as "spaghetti code" Most experienced programmers will never use the GoTo statement. ...
Sub GotoStatementDemo()Dim Number, MyString Number = 1 ' 设置变量初始值。' 判断 Number 的值以决定要完成那一个程序区段(以“程序标签”来表式)。If Number = 1 Then GoTo Line1 Else GoTo Line2 Line1:MyString = "Number equals 1"GoTo LastLine ' 完成最后一行。Line2:' 下列的...
Sub GotoStatementDemo() Dim Number, MyString Number = 1 ' 设置变量初始值。 ' 判断 Number 的值以决定要完成那一个程序区段(以“程序标签”来表式)。 If Number = 1 Then GoTo Line1 Else GoTo Line2 Line1: MyString = "Number equals 1" ...
Sub GotoStatementDemo() Dim Number, MyString Number =1' 设置变量初始值。 ' 判断 Number 的值以决定要完成那一个程序区段(以“程序标签”来表式)。 If Number =1ThenGoTo Line1ElseGoTo Line2 Line1: MyString ="Number equals 1" GoTo LastLine' 完成最后一行。
vba goto的用法合集 python goto语句的用法 Python goto 语句的用法 一、具体用法 首先安装一个 goto 的包(因为官方是没有 goto 语句的) pipinstallgoto-statement 具体的语法注意:对需要使用 goto 的函数,前面加个@patch. fromgotoimportwith_goto @with_goto defrange(start,stop): i=start result=[] label...