Objectives
ü To be
able to create, execute, and save a VB project
ü To
interactively design a simple interface by selecting, placing and sizing screen
objects from the toolbox
ü To be
able to use the Pointer to select controls
ü To be
able to customize the Form using properties
ü To use
and be familiar with the Label control and its properties
ü To use
and be familiar with Shapes and their common properties
ü To be
familiar with VB events
![]()
IN FOCUS: FORMS
Forms are the windows that you see at runtime. They serve as containers of controls such as
Labels and CommandButtons.
The following table lists the Form’s properties.
|
Property |
Description |
|
BackColor |
Specifies
the Form’s background color.
Programmer selects a color from the Color Palette or specifies a color
in Hex format. |
|
BorderStyle |
Determines
how the Form window appears. It also specifies whether the user can resize
the Form and determines what kind of Form you wish to display (0: None, 1:
Fixed Single, 2: Sizable, 3: Fixed Dialog, 4: Fixed ToolWindow, 5: Sizable
ToolWindow) |
|
Caption |
Specifies
the text on the Form’s Title Bar at runtime. |
|
Enabled |
Boolean.
Determines whether the Form is active. A disabled Form does not trigger an
event. All controls on the Form are
also disabled. |
|
Height |
Specifies
the height of the Form in twips. A
twip is 1,440th of an inch) |
|
Icon |
Specifies
the filename of the icon graphic image that appears in the Form’s Title Bar |
|
Left |
Specifies
the number of twips from the Label’s left edge to the Form window’s left
edge. |
|
MaxButton |
Boolean.
Specifies whether a maximize button appears on the Form. |
|
MinButton |
Boolean.
Specifies whether a minimize button appears on the Form. |
|
MousePointer |
Determines
the image of the mouse cursor when the user moves the mouse pointer over the
Form. |
|
Moveable |
Boolean.
Specifies whether the user can move the Form at runtime. |
|
Picture |
Determines
the graphic image that appears on the Form’s background. |
|
StartUpPosition |
Determines
the state (centered or default) of the Form at application startup. |
|
Top |
Specifies
the number of twips from the Label’s top edge to the Form window’s top edge. |
|
Visible |
Boolean. Determines whether the Form appears (True)
or is hidden from the user (False) at runtime. |
|
Width |
Holds
the width of the Form in twips. |
|
WindowState |
Determines
the initial state of the Form (0: Normal, 1: Minimized, 2: Maximized) |
Form’s Events
Form events are events that the Form can
accept. The following are common ones:
|
Event |
Description |
|
Load |
Occurs
when a Form is loaded. |
|
Unload |
Occurs
when a Form is about to be removed from the screen. |
|
Resize |
Occurs
whenever a Form is resized, either by user interaction or through code. |
|
Activate |
Occurs
when an object becomes the active
Form. An active Form appears in the
foreground with a highlighted Title Bar. |
|
Deactivate |
Occurs
when a Form is no longer active. |
More events are discussed in Lesson II.
IN FOCUS: LABELS
Labels hold text that appears on the Form. Labels cannot be edited directly – an
explicit code assigning a new caption to the Label should be carried
out. You use a Label, as its
name obviously implies, to label a control, to provide instructions, etc. The following table lists most common Label
control properties.
|
Property |
Description |
|
Alignment |
Determines
whether the text appears 0: left-justified, 1: right-justified, or 2:
centered within the Label’s boundaries. |
|
AutoSize |
Boolean. Enlarges the Label’s size properties, when
True, if you assign a caption that is too large to fit in the current Label’s
boundaries at runtime. If False, the
Label truncates the caption. |
|
BackColor |
Specifies
the Label’s background color.
Programmer selects a color from the Color Palette or specifies a color
in Hex format. |
|
BackStyle |
Determines
whether the background shows through the label of if the Label covers up it
background text, graphics, and color. |
|
BorderStyle |
0:
None, 1: Fixed Single. Determines whether a single-line border appears around
the Label. |
|
Caption |
Holds
the text that appears on the Label. |
|
Enabled |
Boolean.
Determines whether the Label is active. A disabled Label does not trigger an
even procedure. |
|
Font |
Specifies
the font of the text. Clicking this
property will invoke a font dialog box in which you can set the font name,
style, and size. |
|
ForeColor |
Specifies
the color of the text. Programmer selects a color from the Color Palette or
specifies a color in Hex format. |
|
Height |
Specifies
the height of the Label in twips. |
|
Left |
Specifies
the number of twips from the Label’s left edge to the Form window’s left
edge. |
|
MousePointer |
Determines
the image of the mouse cursor when the user moves the mouse pointer over the
Label. |
|
TabIndex |
Specifies
the order of the Label in the focus order. |
|
TabStop |
Boolean. Determines whether the Label can receive
the focus. |
|
ToolTipText |
Holds
the text that appears as a tooltip at runtime. A tooltip is a pop-up
description box that appears when the user rests the mouse pointer over a
control. |
|
Top |
Specifies
the number of twips from the Label’s top edge to the Form window’s top edge. |
|
Visible |
Boolean. Determines whether the Label appears
(True) or is hidden from the user (False) at runtime. Invisible Labels are only invisible at
runtime. |
|
Width |
Holds
the width of the Label in twips. |
|
WordWrap |
Determines
whether the Label expands to fit its caption. |
IN FOCUS: RUNNING, PAUSING, & STOPING A VB PROGRAM
You can run, pause, and stop VB applications by pressing
the control buttons on the Tool Bar or by clicking the Run menu
and selecting the appropriate menu item.
|
|
Click this to run the application. |
|
|
Click this to pause the application. |
|
|
Click this to terminate the application. You can also click the Close button
on the Title Bar of the application. |
IN FOCUS: SELECTING
CONTROLS
The Pointer is one indispensable tool. When we move
and resize control or when we modify the properties of a control, we use the
Pointer tool. How do we use the Pointer
in selecting controls?
§
If you want to select a control, simply click the Pointer
on the Toolbox and click the control you would like to select.
§
If you want to select multiple controls, hold down the Ctrl
key and click each control. You may also just lasso multiple controls by
dragging a square around the controls using the mouse.
IN FOCUS: SHAPE CONTROL
The Shape control provides you with basic shape
objects such as Rectangles, Squares, Ovals, and Circles. The following Form shows each of
these shapes:

When you drag a Shape control to the Form, a
rectangle is displayed. To change the
shape, simply change the Shape property to:
0: Rectangle
1: Square
2: Oval
3: Circle
4: Rounded Rectangle
5: Rounded Square
By default, Shapes are transparent – all you see is
the outline of a white shape. If you
want the color of the Form to appear through the Shape, (the
Shape shows whatever it covers), set the BackStyle to 0: Transparent.
You can fill Shapes with a color by setting the FillStyle
property to 0: Solid and setting a color to the FillColor
property. You may also fill the Shapes
with one of the pre-defined patterns: 2: Horizontal, 3: Vertical Line, 4:
Upward Diagonal, 5: Downward Diagonal, 6: Cross, and 7: Diagonal Cross.

You can also modify the border (or outline) of the Shapes. The BorderStyle property determines
how the Shape’s borders would look like. When set to 0: Transparent, you do not see any
border. The border can also be 1:
Solid Line (the default), 2: Dashes, 3: Dots, 4: Dash Dots, 5: Dash Dot Dots,
6: Inside Solid. The BorderWidth
determines the width of the Shape’s border. Default value is 1. The bigger this value, the thicker the
border. The Visible property
determines whether the Shape should be displayed (True) or not (False)
at runtime.
![]()

![]()
§
Display the Maximize and Minimize buttons.
§
Your name should be displayed in Arial font, Size 18, Bold,
color Blue.
§
Display a rectangle Shape control (BorderWidth=3,
BorderStyle=Dots) around the Label.
§
Label should be transparent.
§
Form should have a white Background color.
§
Display an icon on the Title Bar (icon file will be
provided by the instructor).
[ Home ]