# Bouncing Ball

I'm trying to make a shape (RedBall), bounce around inside a frame on a form but I'm not sure how to make the IF statement. Any help appreciated.

This is the code I'm using at the mo

If (RedBall.Top < 2400 And RedBall.Left < 3960) Then
RedBall.Top = RedBall.Top + 30
RedBall.Left = RedBall.Left + 30
If (RedBall.Top > 0 And RedBall.Left > 0) Then
RedBall.Top = RedBall.Top - 30
RedBall.Left = RedBall.Left - 30
End If
End If
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Option Explicit

Private Sub Command1_Click()
Timer1.Enabled = Not Timer1.Enabled
End Sub

Private Sub Timer1_Timer()
Static bVertical As Boolean
Static bHorizontal As Boolean
Select Case RedBall.Top
Case Is > frame1.Height - RedBall.Height
RedBall.Top = RedBall.Top - 10
bVertical = False
Case Is < 0
RedBall.Top = RedBall.Top + 10
bVertical = True
Case Else
If bVertical Then
RedBall.Top = RedBall.Top + 10
Else
RedBall.Top = RedBall.Top - 10
End If
End Select
Select Case RedBall.Left
Case Is > frame1.Width - RedBall.Width
RedBall.Left = RedBall.Left - 10
bHorizontal = False
Case Is < 0
RedBall.Left = RedBall.Left + 10
bHorizontal = True
Case Else
If bHorizontal Then
RedBall.Left = RedBall.Left + 10
Else
RedBall.Left = RedBall.Left - 10
End If
End Select
End Sub

Experts Exchange Solution brought to you by