For loop not initialized (VBScript)

The sequence of execution in your script jumped into the middle of a For...Next loop. This causes an error because For...Next loop counters must be initialized. The following demonstrates the correct structure of a For...Next loop.

                      For counter = start To end [Step step]
    [statements]
    [Exit For]
    [statements]
Next

To correct this error

  • Remove the jump into the For...Next loop.

  • Make sure that the For...Next loop includes all the necessary parts.

See Also

Concepts

Looping Through Code

Reference

For...Next Statement

Do...Loop Statement

Exit Statement

For Each...Next Statement

While...Wend Statement