猜数字先看源码:
这里面没有用循环而是用到了递归
Randomize dim a,b,c c = msgbox ("如果什么也不输入,下一步点击确定键,自动退出游戏,另需要提示随机数吗",1,"提示") a = int(round (rnd*100)) b = inputbox("请输入一个1~100整数:","猜数字") mysub a,b,c sub mysub (a,b,c) if (c=1) then msgbox ("随机数:"&a&",我输入的:"&b) end if if not isnumeric(b) then msgbox "退出游戏" else select case sgn(b-a) case 0 msgbox "恭喜答对" case 1 msgbox "输入的数值太大了" b = inputbox("请输入一个1~100整数:","猜数字") mysub a,b,c case -1 msgbox "输入的数值太小了" b = inputbox("请输入一个1~100整数:","猜数字") mysub a,b,c end select end if end sub
msgbox信息提示框:如果有返回值的话,需要括号,若只是简单的弹出提示,是不需要括号()
sub子程序:如果传入的参数比较多了,那么不需要括号,只有一个可以有括号
是否关机的源码:
on error resume next dim a,WSHshell a = msgbox ("是否在一分钟内关机?",1,"关机界面") set WSHshell = wscript.createobject("wscript.shell") if (a =1) then WSHshell.run "cmd.exe /c shutdown -s -t 60 -c ""一分钟内关机...""",0,true else WSHshell.run "cmd.exe /c shutdown -a",0,true end if
on error resume next :无论发生什么错误都要执行下去
注意:如果执行后在dos窗口输入“shutdown -a ”,看有没有需要终止的关机代码,若是没有,就把上面关机代码给删掉再写一遍
- 海报