0
if (some condition) --suppose this gets true
    ....
    ....
elseif (some condition)--this also gets false
    ...
    ...
else 
    ... --this else condition becomes false
    ...
    if (some condition)
        ..
    else
        ..
    endif-- stops execution when it gets here,doesnt moves on to next endif

endif

现在我想做的是跳过其他部分。为此,我将跳过它,直到它获得一个 endif 关键字。但是当它在 else 部分中获得第一个 endif 时,它会停止执行。如何跳过该 endif 以使其与 if 的确切 endif 匹配。真的很混乱,请帮助...

4

1 回答 1

3

你需要让你的条件逻辑直截了当:

magicNumber = 42

If magicNumber = 42 Then
    wscript.echo "Magic number is 42!"
ElseIf magicNumber > 23 Then
    wscript.echo "Magic number is more than 23"
Else
    wscript.echo "Magic number is 23 or less"
    If magicNumber <= 0
         wscript.echo "Woah! Magic number is negative!"
    else
         wscript.echo "Phew, at least Magic number is not zero or negative"
    End if
    wscript.echo "Bye!"
End if
wscript.echo "End."

' Output: 
' Magic number is 42!
' End.

因为第一个条件是True,所以不会测试和执行其他条件。

于 2013-02-27T14:35:04.270 回答