I want to have a race between 2 picboxs using rnd.
Now it works but fails to stop when we have a winner as I get an infinite loop with msgbox.
Code:Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick pb1.Left += Int(Rnd() * 20) pb2.Left += Int(Rnd() * 20) If pb1.Left <= 0 Or pb1.Right >= Me.ClientSize.Width Then MsgBox("pb1 wins") pb1.Left = 0 pb2.Left = 0 Timer1.Enabled = False Reset() End End If If pb2.Left <= 0 Or pb2.Right >= Me.ClientSize.Width Then pb2.Left = 0 pb1.Left = 0 MsgBox("pb2 wins") Timer1.Enabled = False Reset() End End If End Sub


Reply With Quote