“Continue” (to next iteration) on VBScript

后端 未结 8 775
陌清茗
陌清茗 2021-02-03 17:43

A colleague and I were trying to figure out a way of doing the equivalent of a \"continue\" statement within a VBScript \"For/Next\" loop.

Everywhere we looked we found

8条回答
  •  名媛妹妹
    2021-02-03 18:02

    I think you are intended to contain ALL YOUR LOGIC under your if statement. Basically:

    ' PRINTS EVERYTHING EXCEPT 4
    For i = 0 To 10
      ' you want to say
      ' If i = 4 CONTINUE but VBScript has no continue
      If i <> 4 Then ' just invert the logic
        WSH.Echo( i )
      End If
    Next
    

    This can make the code a bit longer, but some people don't like break or continue anyway.

提交回复
热议问题