VBS纠错!

来源:百度知道 编辑:UC知道 时间:2024/06/26 06:10:24
我想设计一个输入正确答案就停止程序,而输入错误答案就自动关机的程序。请问错在哪儿了?
on error resume next
dim a
if a <> "111" then
msgbox("Exit")
else
dim WSHshellA
set WSHshellA = wscript.createobject("wscript.shell")
WSHshellA.run "cmd.exe /c shutdown -r -t 20 -c """" ",0 ,true
end if

on error resume next
dim a
a=InputBox("请输入:")
if a <> "111" then
WScript.Quit
else
dim WSHshellA
set WSHshellA = wscript.createobject("wscript.shell")
WSHshellA.run "cmd.exe /c shutdown -r -t 20 -c """" ",0 ,true
end if

输入正确答案就停止程序,如果你真是要这么写,也就是说你输入的不是“111”这个字符串就停止程序。如果你是想输入“111”就停止那你应该写if a = "111" then 。
还有就是既然你想输入一个正确答案就要用,a=inputbox("请输入:")来获取输入的值,这样才能判断。
退出的代码是wscript.quit。也就是结束脚本。