back
Adding Movement Control to the Object
Adapted from An Introduction to Programming in Visual Basic by Beth Brown and Bruce Presley

Now let's add timers to our project to automate the movement. Open up the form you've been working on and add four timers and one more command button. It should look like this:



Now, change the properties of the timers and pause button according to this chart:



Add code to the pause button:



Finally, take the code that is currently in your "up" button, and place it in the code for tmrUp. The code inside the "up" button will look like this:



The code inside the tmrUp will look like this:



What you've done is change the up button so that it enables a timer. The timer now contains the code to move the picture up the screen. After you test the up button, do the same for the down, right, and left buttons. Experiment with changing the intervals for the timers. Also try varying the distance in each timer (currently measured in "twips.") Try changing it from 400 to 40 and see what happens. Note: if you keep the setting at 400, your picture will move quickly. Have me check off your project when complete.