[size=2][color=#0000ff]Protected[/color][/size][size=2] [/size][size=2][color=#0000ff]Overridable[/color][/size][size=2] [/size][size=2][color=#0000ff]Sub[/color][/size][size=2] TimerOnTick([/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] obj [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Object, [/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] ea [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.EventArgs) [/size][size=2][color=#0000ff]Handles[/color][/size][size=2] tmrA.Tick
[/size][size=2][color=#008000]' Obtain the Graphics object exposed by the Form.
[/color][/size][size=2][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] grfx [/size][size=2][color=#0000ff]As[/color][/size][size=2] Graphics = CreateGraphics()
[/size][size=2][color=#008000]'Draw the bitmap containing the ball on the Form.
[/color][/size][size=2]grfx.DrawImage(bitmap, _
[/size][size=2][color=#0000ff]CInt[/color][/size][size=2](ballPositionX - ballBitmapWidth / 2), _
[/size][size=2][color=#0000ff]CInt[/color][/size][size=2](ballPositionY - ballBitmapHeight / 2), _
ballBitmapWidth, ballBitmapHeight)
grfx.Dispose()
[/size][size=2][color=#008000]' Increment the ball position by the distance it has
[/color][/size][size=2][/size][size=2][color=#008000]' moved in both X and Y after being redrawn.
[/color][/size][size=2]ballPositionX += ballMoveX
ballPositionY += ballMoveY
[/size][size=2][color=#008000]' Reverse the ball's direction when it hits a boundary.
[/color][/size][size=2][/size][size=2][color=#0000ff]If[/color][/size][size=2] ballPositionX + ballRadiusX >= ClientSize.Width _
[/size][size=2][color=#0000ff]Or[/color][/size][size=2] ballPositionX - ballRadiusX <= 0 [/size][size=2][color=#0000ff]Then
[/color][/size][size=2]ballMoveX = -ballMoveX
[/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]If
[/color][/size][size=2][/size][size=2][color=#008000]' Set the Y boundary at 40 instead of 0 so the ball does not bounce
[/color][/size][size=2][/size][size=2][color=#008000]' into controls on the Form.
[/color][/size][size=2][/size][size=2][color=#0000ff]If[/color][/size][size=2] ballPositionY + ballRadiusY >= ClientSize.Height _
[/size][size=2][color=#0000ff]Or[/color][/size][size=2] ballPositionY - ballRadiusY <= 1 [/size][size=2][color=#0000ff]Then
[/color][/size][size=2]ballMoveY = -ballMoveY
[/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]If
[/color][/size][size=2][/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]Sub [/color][/size]