In an animation an object is repeatedly loaded at successive places across the screen so it appears to move.  You can use a timer to control the animation speed.

Set up a form like this:  


(Here is a car image that you can copy and save)  

The timer controls the speed of the car - it is not visible when the application runs.  Set the following properties for tmrSpeed:

Here is the code you will need:

Private Sub cmdStart_Click()
      imgCar.Left = 50   'put the car back to the start
      tmrSpeed.Enabled = True   'start the timer
End Sub

Private Sub cmdStop_Click()
      tmrSpeed.Enabled = False   'stop the timer
End Sub

Private Sub tmrSpeed_Timer()
      imgCar.Left = imgCar.Left + 30   'move the picture across 30
End Sub 

The timer control works differently from the other controls.   

The Interval property on a Timer control sets the number of milliseconds between calls to the Timer event. If it's set to 0, it disables the Timer control. 

The timer will run whenever it is Enabled and will stop when it is disabled. 

Take care with the timer interval because even when the Enabled property is True, the timer won't be enabled if the interval is 0.  

It is not wise to set the timer interval to 0 as a method of stopping your timer, as then your applications will not upgrade to newer versions of Visual Basic.

In the example above, the tmrSpeed_Timer() event (moving the image across 30 twips) will occur every 20 milliseconds.

 

Test your Application

Test your application and make any necessary modifications.  Adjust the timer control settings until the car moves at the speed you want it to.

You can create a background for your animation by setting the picture property for the form.  (You may wish to draw a background in a paint program first)

 


Choose one of the following images and design an animation of a balloon moving up the screen. 

 

Now design another animation to move this balloon diagonally from the bottom left corner of the form to the top right corner.

Modify your first animation to make the balloon bounce up and down.