Solved 'Loop without Do' (1 Viewer)

NewAccount

New member
Local time
Today, 11:34
Joined
Nov 26, 2022
Messages
7
Hello! I am trying to make a message box spam prank and I don't get why I get the 'loop' without 'do' error.
Here's my code:
Code:
do
a=msgbox("Magenta.vbs failed to open. Try again?", 4+48, "Magenta.vbs")
if a = yes then
msgbox "FATAL ERROR: Magenta.vbs has run because it is corrupted, or infected. Reinstall the program and try again.", 0+16,"Magenta.vbs"
if a = no then
exit do
end if
loop
Can you help me how to fix this?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:34
Joined
May 7, 2009
Messages
19,246
use:

do While True
...
...
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:34
Joined
May 7, 2009
Messages
19,246
will this helping?
Code:
do while true
a=msgbox("Magenta.vbs failed to open. Try again?", vbQuestion+vbYesNo, "Magenta.vbs")
if a = vbYes then
msgbox "FATAL ERROR: Magenta.vbs has run because it is corrupted, or infected. Reinstall the program and try again.", 0+16,"Magenta.vbs"
end if
if a = vbNo then
exit do
end if
loop
 

NewAccount

New member
Local time
Today, 11:34
Joined
Nov 26, 2022
Messages
7
will this helping?
Code:
do while true
a=msgbox("Magenta.vbs failed to open. Try again?", vbQuestion+vbYesNo, "Magenta.vbs")
if a = vbYes then
msgbox "FATAL ERROR: Magenta.vbs has run because it is corrupted, or infected. Reinstall the program and try again.", 0+16,"Magenta.vbs"
end if
if a = vbNo then
exit do
end if
loop
Still getting the error...
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 22:34
Joined
Feb 28, 2001
Messages
27,319
You need to set a breakpoint on the code, probably best on the "If a = vbYes" statement, and when the break occurs, hover the mouse over the variable "a" to see what it is. You can hover on the vbYes and vbNo values to see which one of them it matches.

You have a low post count so we don't know your level of expertise. Therefore, if you aren't sure about setting breakpoints, ...

 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 22:34
Joined
Feb 28, 2001
Messages
27,319
By the way, the original sample failed because you had unbalanced IF/END IF on the first IF statement. If you actually did what Arnel said to do, that should have been better, but we can't see your actual code, only what was suggested.
 

isladogs

MVP / VIP
Local time
Today, 04:34
Joined
Jan 14, 2017
Messages
18,261
Minor variation
Code:
Sub Test()

Dim a

Do While True
a = MsgBox("Magenta.vbs failed to open. Try again?", vbQuestion + vbYesNo, "Magenta.vbs")
If a = vbYes Then
    MsgBox "FATAL ERROR: Magenta.vbs has not run because it is corrupted, or infected. Reinstall the program and try again.", vbCritical, "Magenta.vbs"
Else
    Exit Do
End If
Loop
End Sub

You could also use Do Until False ... instead. Both tested and working.
 

NewAccount

New member
Local time
Today, 11:34
Joined
Nov 26, 2022
Messages
7
Minor variation
Code:
Sub Test()

Dim a

Do While True
a = MsgBox("Magenta.vbs failed to open. Try again?", vbQuestion + vbYesNo, "Magenta.vbs")
If a = vbYes Then
    MsgBox "FATAL ERROR: Magenta.vbs has not run because it is corrupted, or infected. Reinstall the program and try again.", vbCritical, "Magenta.vbs"
Else
    Exit Do
End If
Loop
End Sub

You could also use Do Until False ... instead. Both tested and working.
Thx! Now it's working.
I made some changes to it, so it works as I wanted it to.
Here's the changed version:
Code:
dim a
a=msgbox("Magenta.vbs failed to open. Try again?", 4+48, "Magenta.vbs")
if a = vbYes then
do until false
msgbox "FATAL ERROR: Magenta.vbs failed to run because it is corrupted, or infected. Reinstall the program and try again.", 0+16,"Magenta.vbs"
loop
else
end if
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 04:34
Joined
Jan 14, 2017
Messages
18,261
Thx! Now it's working.
I made some changes to it, so it works as I wanted it to.
Here's the changed version:
Code:
dim a
a=msgbox("Magenta.vbs failed to open. Try again?", 4+48, "Magenta.vbs")
if a = vbYes then
do until false
msgbox "FATAL ERROR: Magenta.vbs failed to run because it is corrupted, or infected. Reinstall the program and try again.", 0+16,"Magenta.vbs"
loop
else
end if

You're welcome.
As you're probably aware, using the message box values has the same effect as using the constants
e.g. 48=vbExclamation, 0 = vbOKOnly
The 0 is superfluous in this case as its the default value

Full list of constants/values is here:
 

Users who are viewing this thread

Top Bottom