例如:
Select Case (x)
Case 1
If ... Then
***Break***
End If
Response.Write( ... )
Case Else
Response.Write( ... )
End Select
例如:
Select Case (x)
Case 1
If ... Then
***Break***
End If
Response.Write( ... )
Case Else
Response.Write( ... )
End Select
要跳入 VBScript,您必须进入Exit
一个循环(或一个子/函数,(c)@Andrevinsky):
Option Explicit
Dim i
For i = 1 To 3
Do ' Jumper Do
Select Case i
Case 1, 2
WScript.Echo i, "A"
If i = 2 Then
WScript.Echo i, "B"
Exit Do
End If
WScript.Echo i, "C"
Case Else
WScript.Echo i, "D"
End Select
WScript.Echo i, "E"
Exit Do
Loop ' Jumper Loop
WScript.Echo i, "F", "---------"
Next
输出:
1 A
1 C
1 E
1 F ---------
2 A
2 B
2 F ---------
3 D
3 E
3 F ---------
问题已经得到解答,但仅供您参考,您可以使用此构造(我将条件Apples = Pears
作为您的If ... Then
条件):
Select Case True
Case (Apples = Pears)
' Do nothing, so it just breaks out of the select construct
Case (x = 1)
Response.Write( ... )
Case Else
Response.Write( ... )
End Select
如果您将选择包围在 a 内,do loop
则可以使用exit do
它来退出选择。
do
select case i
case 1
...do stuff...
case 2
...do stuff...
case 3
exit do
case else
...do stuff...
end select
exit do
loop
请注意exit do
结尾之前的,loop
因为您不想实际循环。