Public Class frmBall

  Dim x As Integer = 1
  Dim y As Integer = 1

  Private Sub frmBall_Load(ByVal sender As System.Object,
                           ByVal e As System.EventArgs) Handles MyBase.Load
    Timer1.Enabled = True
  End Sub

  Private Sub Timer1_Tick(ByVal sender As System.Object,
                          ByVal e As System.EventArgs) Handles Timer1.Tick
    If picBall.Left <= 0 Or
             picBall.Left >= (Me.ClientSize.Width - picBall.Width) Then
      x = -x
    End If
    picBall.Left += x
    If picBall.Top <= 0 Or
            picBall.Top >= (Me.ClientSize.Height - picBall.Height) Then
      y = -y
    End If
    picBall.Top += y
  End Sub

End Class
