代码
Option ExplicitDim Money, Index1, Cen, Finish
Private Sub Command1_Click()
Dim i
If Option1(0).Value = False And Option1(1).Value = False Then
MsgBox "您还没有选择选手!", , "提示"
Else
Timer1.Enabled = True
Command1.Enabled = False
Money = Money - 20: Label2.Caption = Money
Do
Index1 = CInt(Rnd * 1)
Cen = CInt(Rnd * 20) + 20
Image1(Index1).Move Image1(Index1).Left + Cen
Delay (10)
Loop Until Image1(Index1).Left + Image1(Index1).Width > Finish
If Option1(Index1).Value = True Then
MsgBox "你赢了"
Money = Money + 60
Label2.Caption = Money
Else
MsgBox "你输了"
End If
If Money = 0 Then
MsgBox "你没有赌注了"
Else
Command1.Enabled = True
End If
For i = 0 To 1
Image1(i).Left = 1200
Next i
For i = 0 To 1
Option1(i).Value = False
Next i
Timer1.Enabled = False
End If
End Sub
Private Sub Form_Load()
Dim i
Timer1.Enabled = False
Image2.Visible = False
Image3.Visible = False
For i = 0 To 1
Option1(i).Value = False
Next i
Money = 100
Label2.Caption = Money
Finish = 8000
End Sub
Private Sub Timer1_Timer()
Static Flag As Integer
If Flag - 2 = 0 Then Flag = 0
If Flag = 0 Then Image1(1).Picture = Image2.Picture
If Flag = 1 Then Image1(1).Picture = Image3.Picture
Flag = Flag + 1
End Sub
Public Sub Delay(X As Long)
On Error Resume Next
Dim TStart As Single
TStart = Timer
While (Timer - TStart) < (X / 1000)
DoEvents
Wend
End Sub