Software Development

  Lecture Notes

Shape Move Program

This tutorial shows you how to create a simple shape moving program in Visual Basic.


Create a New Project

Draw the Graphical User Interface

Edit the Properties

Add Program Code

Run the Program



This tutorial will enable you to: -

  • Create another simple VB application

  • Become familiar with some basic Control properties, such as Name, BackColor BackStyle, Height, Left, Top and Width

Create a New Project

The program you will create contains four shapes which follow a mouse pointer around. One shape follows the mouse pointer, the other three are moved into equivalent positons on the screen.

Activity A

  1. If you wish to see the program running, click here.

Note: Not all systems will be able to run this program.

To start, open Visual Basic and create a new project. You should be able to find Visual Basic by clicking on the Windows Start button and then selecting Visual Basic from the Program Menu.  Select Standard.EXE and then click on the Open button.

As soon as the VB development environment appears, save your new project and form files to an empty folder. It is always advisable to save new project files to an empty folder and not save to a folder that already contains VB files from a different project.

Draw the Graphical User Interface

Now you are ready to create the graphical user interface (GUI.) Add the following controls to the form:-

  • One Command Button
  • Five Labels
  • Four Shape controls.

Position the controls so your form looks similar to mine, as shown below.

Edit the Properties

Now for most of the controls on your form, you need to change some Properties in the Properties window.

To see which properties to change, open the document below and print it out or save it. It tells you which controls and which properties to change.

Open this document - it shows the properties to change

For example, the first table in the document shows properties that need changing for the Command Button. Both the Name and Caption property needs to be changed, as shown below:-







Continue to change the properties, as shown in the document.

Add Program Code

Now you need to add code to make the shapes move when the user moves their mouse.. Go to the code window of your form by clicking on the white icon  on the Project Explorer window.  Alternatively select Code from the View menu.  

Add the following code:-


Run Your Program

To execute a program in VB, just click on the Run button on the main horizontal toolbar near the top of the VB window, the little arrow. 

Alternatively, press F5.  Or, or select Start from the Run menu.

To stop your program running, click your Close button. If for some reason your Close button does not work, then click your program's  button.   Don't click VB's button. 

Activity B

  1. If you haven't changed your form's background color, why not do that now. Always try and make your program as attractive looking as possible.

  2. What could you do to change or enahnce this program. Perhaps you could change the shapes from rectangles to different shapes. What about adding options allowing the user to change the shapes, say from rectangles to circles.

Congratulation! You have now created another program.

That's it!!





  Unit Information



Scheme of Work

Notes &Tutorials



Books & Things