72Views3Replies

Author Options:

How can I fix this? VBS Answered

x =msgbox("Do you wish to restart?",4+16+4096,"Critical Errror")
if VByes Then CreateObject("WScript.Shell").Run "shutdown.bat"
ElseIf VBno Then CreateObject("WScript.Shell").Run "shutdown.bat"

I want both the yes and no to do the same thing when pressed

Discussions

0
None
sevinstraus

5 years ago

Are you getting an error trying to do this? It does not look like complete VB code.

0
None
metalshifletsevinstraus

Answer 5 years ago

It runs ok if I take off the last line, but not with the last line

0
None
verence

5 years ago

What flavour (i.e. version) of Visual Basic?

Your if is not using the x variable (the result of the MessageBox)

Maybe you want something like:

if x=VBYes then
CreateObject [...] "restart.bat"
else
CreateObject [...]"shutdown.bat"

No need for the elseifunless there IS a third option to leave the MsgBox.