VBS猜數游戲


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 input
13 input = int(inputbox("Guess it")) 14 
15 '注意:while語句的語法是: while condition ... wend (不加then)
16 
17 while n <> input  
18 tryTime = tryTime+1
19 if input>n then
20 input = int(inputbox("Too big! Try again!")) 21 else 
22 input = int(inputbox("Too small! Try again!")) 23 end if
24 wend 25 
26 if tryTime=1 then
27 msgbox "Genius! Buy a lottery ticket quickly!"
28 elseif tryTime=2 then
29 msgbox "666"
30 elseif tryTime=3 then
31 msgbox "NB"
32 elseif tryTime=4 then
33 msgbox "Cool!"
34 elseif tryTime=5 then 
35 msgbox "Good!"
36 elseif tryTime=6 then 
37 msgbox "Not Bad!"
38 elseif tryTime=7 then
39 msgbox "Unfortuntate!"
40 elseif tryTime=8 then
41 msgbox "Idiot!"
42 else 
43 msgbox "SB!"
44 end if
45 
47 if msgbox("ReTry?",vbOK)<>1 then
48 msgbox "Bye!"
49 wscript.quit 50 end if
51 
53 wend

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM