急~下星期交~
求code(最好) OR 直接指導~
版面:5架車打橫行,以線為終結。
有制寫住START
玩法:按START, Inputbox出現要玩家輸入車號碼
輸入後…
車開始自己動去終點到終點,message box 出現
估對: message box話佢嬴左
估錯: message box話佢輸左
按OK,有另一個message box問佢要5要玩多次
Yes:繼續
No:結束
p.s.我覺得最難係要d車開始自己動去終點同埋去到終點就停
有位人兄答我:
Private choice As String ' <-- Module level
Private Sub StartButton_Click()
Dim I As Integer
For I = 0 To 4
Image1(I).Left = 10000
Next
choice = InputBox("Please enter the number of the car", "car", " number")
Timer1.Enabled = True ' <-- 開始 Timer
End Sub
Private Sub Timer1_Timer()
Dim I As Integer
Dim race_over As Boolean
race_over = False
Randomize
For I = 0 To 4
Image1(I).Left = Image1(I).Left - (Int(Rnd * 100) + 100)
If Image1(I).Left < 500 Then ' <-- 到終點
Timer1.Enabled = False ' <-- 停止 Timer
If choice = CStr(I) Then '<-- 估對
MsgBox "Win"
Else
MsgBox "Loose"
End If
race_over = True
Exit For ' <-- 離開 For Next Loop
End If
Next
If race_over Then
If MsgBox("Do you want to play again?", vbYesNo, "car") = vbYes Then
StartButton_Click '<-- 再玩過
End If
End If
End Sub
首先多謝個位人兄寶貴既意見~
不過我試過發現有D問題!(當中有D我吾明既)
吾明:
1) Private Sub StartButton_Click() 可以用Private Sub Command1_Click()嗎?
2) Dim I As Integer For I = 0 To 4 Image1(I).Left = 10000 Next上面要來仲咩~
3) 最吾明Timer D code~
4) Dim race_over As Boolean
If choice = CStr(I) Then
未學過~最好5用~用咩取代?
基本上,5要個D我吾明,個programme work 5到!
特別係~(要d車開始自己動去終點同埋去到終點就停)得一架車?
祈求各位幫助~(係個位好人既人兄就最好~)
有人幫我改下就最好~
多謝~