0% found this document useful (0 votes)
46 views5 pages

Lesson I

This document provides an overview of forms, labels, shapes, and other basic controls in Visual Basic. It discusses: - The key properties and functions of forms, including how to customize the form caption, size, and appearance. - Common label properties like font, color, alignment and how labels display text on a form. - The different shape controls (rectangle, oval, etc.), how to customize their color, border, and appearance. - How to run, pause and stop a VB program, and how to select controls using the pointer tool. - An example lesson that walks through creating a new project, adding and customizing a label, and saving the work.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views5 pages

Lesson I

This document provides an overview of forms, labels, shapes, and other basic controls in Visual Basic. It discusses: - The key properties and functions of forms, including how to customize the form caption, size, and appearance. - Common label properties like font, color, alignment and how labels display text on a form. - The different shape controls (rectangle, oval, etc.), how to customize their color, border, and appearance. - How to run, pause and stop a VB program, and how to select controls using the pointer tool. - An example lesson that walks through creating a new project, adding and customizing a label, and saving the work.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

Lesson I.

Forms, Labels, and Shapes

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

Notes
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 Forms properties.
Property
BackColor
BorderStyle

Caption
Enabled
Height
Icon
Left
MaxButton
MinButton
MousePointer
Moveable
Picture
StartUpPositio
n
Top
Visible
Width
WindowState

Description
Specifies the Forms background color. Programmer selects
a color from the Color Palette or specifies a color in Hex
format.
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)
Specifies the text on the Forms Title Bar at runtime.
Boolean. Determines whether the Form is active. A disabled
Form does not trigger an event. All controls on the Form
are also disabled.
Specifies the height of the Form in twips. A twip is 1,440 th
of an inch)
Specifies the filename of the icon graphic image that
appears in the Forms Title Bar
Specifies the number of twips from the Labels left edge to
the Form windows left edge.
Boolean. Specifies whether a maximize button appears on
the Form.
Boolean. Specifies whether a minimize button appears on
the Form.
Determines the image of the mouse cursor when the user
moves the mouse pointer over the Form.
Boolean. Specifies whether the user can move the Form at
runtime.
Determines the graphic image that appears on the Forms
background.
Determines the state (centered or default) of the Form at
application startup.
Specifies the number of twips from the Labels top edge to
the Form windows top edge.
Boolean. Determines whether the Form appears (True) or is
hidden from the user (False) at runtime.
Holds the width of the Form in twips.
Determines the initial state of the Form (0: Normal, 1:
Minimized, 2: Maximized)

Forms Events
Form events are events that the Form can accept. The following are common ones:
Event
Load
Unload
Resize
Activate

Description
Occurs when a Form is loaded.
Occurs when a Form is about to be removed from the screen.
Occurs whenever a Form is resized, either by user interaction
or through code.
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
Alignment
AutoSize

BackColor
BackStyle
BorderStyle
Caption
Enabled
Font
ForeColor
Height
Left
MousePointe
r
TabIndex
TabStop
ToolTipText
Top
Visible
Width
WordWrap

Description
Determines whether the text appears 0: left-justified, 1:
right-justified, or 2: centered within the Labels boundaries.
Boolean. Enlarges the Labels size properties, when True, if
you assign a caption that is too large to fit in the current
Labels boundaries at runtime. If False, the Label truncates
the caption.
Specifies the Labels background color. Programmer selects
a color from the Color Palette or specifies a color in Hex
format.
Determines whether the background shows through the label
of if the Label covers up it background text, graphics, and
color.
0: None, 1: Fixed Single. Determines whether a single-line
border appears around the Label.
Holds the text that appears on the Label.
Boolean. Determines whether the Label is active. A disabled
Label does not trigger an even procedure.
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.
Specifies the color of the text. Programmer selects a color
from the Color Palette or specifies a color in Hex format.
Specifies the height of the Label in twips.
Specifies the number of twips from the Labels left edge to
the Form windows left edge.
Determines the image of the mouse cursor when the user
moves the mouse pointer over the Label.
Specifies the order of the Label in the focus order.
Boolean. Determines whether the Label can receive the
focus.
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.
Specifies the number of twips from the Labels top edge to
the Form windows top edge.
Boolean. Determines whether the Label appears (True) or is
hidden from the user (False) at runtime. Invisible Labels are
only invisible at runtime.
Holds the width of the Label in twips.
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:
1:
2:
3:
4:
5:

Rectangle
Square
Oval
Circle
Rounded Rectangle
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 Shapes 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 Shapes 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.

Lesson in Action

1. Create a new project. When you fire up VB, a New Project dialog box appears. Select
Standard Exe, and click the Open button. If you want another project, just click the File
menu, then New Project.
2. Customize the Form.
Name
frmMain
Caption
My First Visual Basic Application
MinButton
False
MaxButton
False
StartUpPosition
Center Screen
Height
3135
Width
4620
BackColor
White
3. Place a Label control on the form.
4. Customize the Label.
Name
lblBanner
Caption
Welcome to Visual Basic
Font
Arial, Regular
Size
24
BackColor
Yellow
ForeColor
Blue
Width
3735
Height
1215
Top
720
Left
360
5. Run your application by clicking the 4 button.
6. Save your work as Lesson1.vbp. Do this by clicking the File menu, then Save Project.
7. If you want to load your project again, simply click the File menu, then Open Project. A
dialog box appears. Just select the Drive and Directory where your project is saved.

On your Own
1. Create an Application displaying your name. Consider the following specifications:

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).

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy