Understand forms and the controls that you can place
So, how do you
draw design and construct a form for user input or
output? With Visual Basic, you have a
toolbox filled with controls. You can choose which
controls you want by dragging them onto a form.
The toolbox is shown below.
If you double-click one
of the controls in the toolbox it places a
copy of that control onto your form.
You can move a control to a different place
on the form if you wish by dragging it.
Open Visual Basic. It should
be on the Start Menu > Programs >
Visual Studio 6 > Visual Basic.
Can you see a toolbox on the left
and a form in the middle? If not ask
your lecturer for help.
Try and make your form look like my
form shown in the picture above. Just
double click a control on the toolbox
and it will be placed in the center of
your form. Then move the control
to the proper position by dragging it.
When you have finished placing all
the controls, you can view what your
program will look like to the user by
running it. Just click on the play icon
in the toolbar near the top of Visual
You should end up with something
program. Just click the link and
It is not a very exciting program at the
moment because I have not added code to
make it do anything useful.
Controls and their Purpose
Each control has a different
purpose. A control will usually either be for displaying
information to the user (output) or for getting information
from the user (input).
What it looks like on the form
What it is for
Used for displaying information to the user
and labelling other controls
Meant for user input. The user can type
information into a text box
Used for selecting or deselecting some
feature of the program.
Displays a list of items in a drop-down list
and the user selects one.
You can place other controls inside a frame
and group them nicely.
Displays a list of items and the user can
Option buttons are usually grouped together
and the user chooses one.
The user clicks the command button.
E.g. OK, Cancel etc.
Used to get your program to execute code at
You can display pictures inside this control
The slider allows the user to scroll things
such as text inside a text area, or a
picture that is too large to display all at
Like the vertical scrollbar, this allows the
user to scroll.
Here are some controls you can
Fill in the form
below. Then click the Submit command
Changing Control Properties
Some of the controls in your
program can be made more useful by setting the
control's properties. To change the property of
a control in Visual Basic, you need to select
that control and change the property value in
the properties window. The picture
below shows the ListBox selected.
The properties window is on the right and I am
adding the numbers 1, 2, 3, 4 to the List property. Then the ListBox will display these numbers.
Here are some useful properties.
There are many others.
Property - this changes the text that is
displayed by a control. I.e. a label's
Property - you can add items for a ComboBox or ListBox to
Property - you can add a picture to your PictureBox.
The picture shows the difference when I
change some of the property values of the
I changed the caption of the
Label to Angela
I added the items 1, 2, 3 and 4 to
the ListBox list
I added a picture to the
In the form you created in
Activity A, change the following
Change your label's Caption property so it
displays your name
Use the List property to change your ListBox so it displays
the numbers 1, 2, 3 and 4.
Add a picture to your PictureBox using
the Picture property.