Organising Your First Project

Organising your first project

The first step is to create a project template within VB, to organise and store your work.
This will consist of a menu structure with headings that will let you access the many
exercises and examples you complete.

· Open VisualBasic 6.0
· Use the file menu to open a new project with a blank form.
· Use the properties window to set
– Main.frm as the form name.
– My programs as the caption.
– BackColor to White.
– BorderStyle to Fixed Single.
– WindowState to Maximised.

· Find the Menu icon and click on it to select it. Enter the following menu headings:
Introduction with indented subheadings of
Click OK after each menu caption and name are typed.

· Click on Quit menu heading and enter the following code. This procedure is used to
exit from running the project display and return to the design screens.
Private Sub Quit_Click()
Unload me
End Sub

· Use the function key to run the application to verify that the Menu structure is
correct and that the Quit procedure is free from error.
· Use the File menu to save your work as Main.frm and (your intitials)Project1.vbp
· Use the file menu to open a new blank form (or the properties window)
· Set the following form properties:
form name as Welcome
caption to Example1
BackColor to White
BorderStyle to Fixed Single
WindowState to Maximised

· Click on the Example 1 main menu heading and enter the following code:
Private Sub Example1_Click()
End Sub

· Save your work and run to ensure that it is free of errors.

· Add two labels, an image and a command button to create a welcome screen. To do
Select label icon from the toolbox. Click towards the centre-top of your form and
position and resize your label as required.
With the label selected, use the properties window to
Change the caption to WELCOME TO VISUAL BASIC
Choose a bright back colour
Set the font (Arial, underline, alignment centred, size 24 point, forecolour blue)
Repeat to add the Enjoy label.
Use the image icon on your toolbox to add the image to your form. Use the
properties window of the image to select a picture.
Use the command Button icon to add the button. Change its caption to RETURN.
Then double-click the button and add the following line of code after the
Command1_Click() procedure.
– Unload Welcome

· Use the file menu to save your work and use to run the application.

Event handlers and scroll bars
Some definitions to learn

· An object is a thing — anything that appears on the screen. An object has a set of
properties. Each property of the object has a value.
e.g. Label.Caption = “Welcome to Visual Basic” where
Label is an object
Caption is a property of label

“Welcome to Visual Basic” is a value of the Caption property.
· Events are things that happen on the screen. Event handlers transfer data to
procedures that complete the task. The results of these procedures are returned
back to other screen objects, e.g. onChange onClick
· A procedure is a group of statements designed to perform a specific task. A
procedure attached to an object, such as a button, is a command used to make
something happen, e.g.
Public Sub Command2_Click()
Text1.Text = “This is a procedure.”
End Sub

Add new form to menu
As each new example and exercise solution is to be added to your project you will need
· add a new form
· set the form properties using the properties window
· click on the main menu icon with the main form displayed to show the menu
· add a new menu heading
· click on the menu heading to show the procedure code
· to the procedure code, add the statement
where FormXX is the new form name.

Disqus Comments