VBS 猜数游戏
2018-11-09 21:19:11
by xutao
1 msgbox "The Swami" ,,"Game" 2 msgbox "The system will give a integer in the range of 1 to 100 randomly, and you are allowed to guess a integer one time! Less tries, more luck" , ,"Rule" 3 while 1=1 '无限循环 4 5 dim tryTime '尝试次数 6 tryTime = 1 7 8 dim n 9 randomize '初始化随机种子,不然每次都会一样10 n = int(rnd*100)11 12 int input13 input = int(inputbox("Guess it"))14 15 '注意:while语句的语法是: while condition ... wend (不加then)16 17 while n <> input 18 tryTime = tryTime+119 if input>n then20 input = int(inputbox("Too big! Try again!"))21 else 22 input = int(inputbox("Too small! Try again!"))23 end if24 wend25 26 if tryTime=1 then27 msgbox "Genius! Buy a lottery ticket quickly!"28 elseif tryTime=2 then29 msgbox "666"30 elseif tryTime=3 then31 msgbox "NB"32 elseif tryTime=4 then33 msgbox "Cool!"34 elseif tryTime=5 then 35 msgbox "Good!"36 elseif tryTime=6 then 37 msgbox "Not Bad!"38 elseif tryTime=7 then39 msgbox "Unfortuntate!"40 elseif tryTime=8 then41 msgbox "Idiot!"42 else 43 msgbox "SB!"44 end if45 47 if msgbox("ReTry?",vbOK)<>1 then48 msgbox "Bye!"49 wscript.quit50 end if51 53 wend