none
Continue For Loop RRS feed

  • Question

  • Hi all.

    I'm struggling to find a way to move on a step in a loop.  The idea of below is that "Next Item" will never be echoed... but I'm getting a syntax error.. what have i done wrong?

    dim i
    for i = 0 to 3
    	if i < 5 then
    		WScript.Echo "1"
    		Continue For
    	end if
    	WScript.Echo "Next Item"
    next

    I appreciate this looks like a rubbish script, but its an extrapolated short test, its just the general idea i need help with.

    Using VBScript.


    • Edited by Ben Bell Thursday, November 28, 2013 5:23 PM
    Thursday, November 28, 2013 5:23 PM

Answers

  • Unfortunately VBScript does not have a "continue" statement that works in For or For Each loops.

    You will need to use an If statement to skip the rest of your loop.

    VBScript does, however, have the Exit For statement to exit from a For or For Each loop.

    Bill

    • Marked as answer by Ben Bell Friday, November 29, 2013 8:34 AM
    Thursday, November 28, 2013 5:59 PM
    Moderator

All replies