什么意思啊? 是跳到下一次循环吗? For ×××××× If ××× Then Goto NextLoop: End If NextLoop: Next
VB中只能用GOTO语句,但是破坏程序的结构,所以不推荐例子如下Line2的语句根本就不会执行Private Sub Command2_Click() Dim i As Integer For i = 0 To 1 If i = 0 Then GoTo Line1 Else GoTo Line2 End If Next Line1: MyString = "i equals 1" GoTo LastLine ' 完成最后一行。 Line2: MyString = "i equals 2" LastLine: Debug.Print MyString ' 显示在“立即”窗口。 End Sub
Dim i As Integer
For i = 0 To 10 Step 2 '支持啊
Next
是跳到下一次循环吗?
For ××××××
If ××× Then
Goto NextLoop:
End If
NextLoop:
Next
Dim i As Integer
For i = 0 To 1
If i = 0 Then
GoTo Line1
Else
GoTo Line2
End If
Next
Line1:
MyString = "i equals 1"
GoTo LastLine ' 完成最后一行。
Line2:
MyString = "i equals 2"
LastLine:
Debug.Print MyString ' 显示在“立即”窗口。
End Sub
退出循环 exit for