3

I am trying to know how to, or even know if it is possible to, loop inside a loop in VBScript.

Here is what logically world work:

Do until y=5
msgbox "msgbox 1 loop test"
Do Until z=5
msgbox "msgbox 2 loop test"
z=z+1
loop
y=y+1
loop

That code should loop 'msgbox 2' 25 times and 'msgbox 1' 5 times but it doesn't.

I have yet to get an answer. This is my last resource of information so please help. Thanks

1 Answer 1

2

You need to initialize your variables:

y = 0
Do until y=5
    msgbox "msgbox 1 loop test " & y
    z = 0
    Do Until z=5
        msgbox "msgbox 2 loop test " & z
        z=z+1
    loop
    y=y+1
loop

Without z = 0 the second loop won't be entered after the first turn.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.