✔ 最佳答案
如果要用到Array,for,if,六合彩是個不錯的範例
下面這個是很經典的猜數字遊戲。
至於六合彩的程式,只需建立一個陣列,再用for逐一隨機選擇數字,讓使用者猜,然後比對,最後確定是頭獎、二獎等,只是個陣列化的猜數字遊戲,如有興趣可以自己發掘。
Game name:Number Guessing Game
VB code:
Randomize
Dim Chances As Long
Dim num As Long
Chances = 10
num = Round(Rnd() * 100) + 1 ’1-100
For i = 0 To Chances - 1
n = InputBox("Please Enter a number(1-100)" & vbCrLf & "You have " & Chances - i & " chance(s)")
If n = num Then
MsgBox "Congratulations!"
Exit For
Else
If n < num Then MsgBox "The number you entered is too small" Else MsgBox "The number you entered is too big"
End If
Next