Results 1 to 2 of 2

Thread: race wont stop

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2007
    Posts
    439

    race wont stop

    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

  2. #2
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: race wont stop

    Try to change the order in the Ifs...

    The first statement must be Timer.Stop... and then pbx.left=0...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width