2008年11月25日 星期二

賽車

image 


Public Class Form1
Dim rWin = 0
Dim gWin = 0
Dim bWin = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Randomize()
Timer1.Interval = 100
Label1.Text = ""
Label2.Text = ""
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
rCar.Left = rCar.Left + Int(Rnd() * 30)
If rCar.Left >= 600 Then
Label1.Text = "紅隊贏!"
rWin = rWin + 1
Label2.Text = "成績統計:紅->" & rWin & " 綠->" & gWin & " 藍->" & bWin
Timer1.Enabled = False
End If
gCar.Left = gCar.Left + Int(Rnd() * 30)
If gCar.Left >= 600 Then
Label1.Text = "綠隊贏!"
gWin = gWin + 1
Label2.Text = "成績統計:紅->" & rWin & " 綠->" & gWin & " 藍->" & bWin
Timer1.Enabled = False
End If
bCar.Left = bCar.Left + Int(Rnd() * 30)
If bCar.Left >= 600 Then
Label1.Text = "藍隊贏!"
bWin = bWin + 1
Label2.Text = "成績統計:紅->" & rWin & " 綠->" & gWin & " 藍->" & bWin
Timer1.Enabled = False
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
rCar.Left = 32
gCar.Left = 32
bCar.Left = 32
Timer1.Enabled = True
End Sub
End Class

沒有留言: