Plz use Visual Basic to write a game

2008-03-26 3:27 am
Plz use Visual Basic to write a game

Game name :

VB code :
更新1:

use For, If, Do or array to do it

回答 (1)

2008-03-26 4:56 am
✔ 最佳答案
如果要用到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


收錄日期: 2021-04-23 20:22:03
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20080325000051KK02971

檢視 Wayback Machine 備份