ayuda ¡¡¡¡ simular una carrera en vb( el numero de corredores debe de ser aleatorio)
"hola amigos del foro mis problema es q no ce como acer para q el numero de corredores sea aleatorio y en todo momento mostrar el tiempo de cada corredor y tambien la velocidad
les agradesco mucho su ayuda "
Option Explicit
Dim i As Integer
'Dim num As Integer
'Dim car As Object
'Dim car2() As Object
Dim j As Integer
'Dim x As Variant
'Dim f As Date
Private Sub Command1_Click()
Randomize
Timer2.Interval = Rnd * 350 'su evento se ejecuta 4 veces por segundo
Timer2.Enabled = True
Image3.Visible = True
Timer1.Interval = Rnd * 350 'su evento se ejecuta 4 veces por segundo
Timer1.Enabled = True
Image2.Visible = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
Timer2.Enabled = False
End Sub
Private Sub Form_Load()
For i = 0 To 7
Image1(i).Visible = False
Next i
i = 0
'Image1(7).Visible = False
End Sub
Private Sub Timer1_Timer()
Image3.Picture = Image1(i).Picture
Image3.Left = Image3.Left + 150 'corre de izq - der
If Image3.Left = Form1.ScaleWidth Then
Timer1.Enabled = False
End If
If i = 7 Then
i = 0
Else
i = i + 1
End If
End Sub
Private Sub Timer2_Timer()
If j = 0 Then
Image2.Picture = Image1(i).Picture
Image2.Left = Image2.Left + 150 'corre de izq - der
If Image2.Left = Form1.ScaleWidth Then
Image2.Picture = LoadPicture
End If
If i = 7 Then
i = 0
Else
i = i + 1
End If
End If
End Sub
|