If statement 如何实际跳过if..elseif..else..endif条件中的语句

If statement 如何实际跳过if..elseif..else..endif条件中的语句,if-statement,vbscript,nested,If Statement,Vbscript,Nested,现在我想做的是跳过其他部分。我将跳过它,直到它得到一个endif关键字。但当它在else部分中获得第一个endif时,它停止执行。如何跳过该endif,使其与if的确切endif匹配。 这真让人困惑,请帮助……您需要弄清楚您的条件逻辑: if (some condition) --suppose this gets true .... .... elseif (some condition)--this also gets false ... ... else

现在我想做的是跳过其他部分。我将跳过它,直到它得到一个endif关键字。但当它在else部分中获得第一个endif时,它停止执行。如何跳过该endif,使其与if的确切endif匹配。
这真让人困惑,请帮助……

您需要弄清楚您的条件逻辑:

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
magicNumber=42
如果magicNumber=42,则
“神奇的数字是42!”
ElseIf magicNumber>23则
wscript.echo“幻数大于23”
其他的
wscript.echo“幻数等于或小于23”

如果magicNumber您需要将条件逻辑弄清楚:

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
magicNumber=42
如果magicNumber=42,则
“神奇的数字是42!”
ElseIf magicNumber>23则
wscript.echo“幻数大于23”
其他的
wscript.echo“幻数等于或小于23”

如果magicNumber在中的条件为true时使用return语句if@NiravRanparaVBScript没有
Return
语句。您必须使用
WScript.Quit
Exit Sub
Exit Function
,具体取决于上下文。如果中的条件为true,请使用return语句if@NiravRanparaVBScript没有
Return
语句。您必须根据上下文使用
WScript.Quit
Exit Sub
Exit Function
。谢谢。实际上,我从未意识到它会从整个代码块中消失。我一直认为如果其他人都是假的话,它会进入最后的else语句。谢谢你。实际上,我从未意识到它会从整个代码块中消失。我一直认为,如果其他人都是假的话,它会进入最后的else陈述。