COMP6 Handouts Part1
COMP6 Handouts Part1
Input Devices
III.
Output Devices
IV.
V.
VI.
VII.
VIII.
IX.
X.
Page 2 of 88
CHAPTER I
INTRODUCTION TO COMPUT ERS
Guide Questions:
1. Do you believe that computers make life easier and better? Explain.
2. List down separately four uses of computers in the home and business.
3. Do you feel any discomfort or anxiety about computers? Explain why or why not.
4. What are the elements of a computer system? List down at least 3 examples of each.
5. Differentiate hardware from software.
6. Name at least 2 examples of computers according to size.
Objectives: At the end of the Chapter, the students will be able to:
understand fundamental computer concepts
realize the importance of computer literacy
know the advantages of electronic data processing systems
be aware of the limitations and failures of computers
be knowledgeable of the different classifications of computers
differentiate the elements of the computer system
classify computers according to their use
Pre-Test:
Multiple Choice. Write the capital letter of your answer on the space provided.
____1. The father of modern computer a) Bill Gates b) Carlos Cabbage c) Charles
Babbage d) Howard Aiken
____2. The word for raw material that is given to a computer for processing. a) data b)
information c) list d) output
____3. Apple Company was formed by a) Gates and Allen b) Jobs and Wozniak c) Eckert
& Mauchly
d) Bardeen and Shockley
____4. The physical component of EDP systems a) firmware b) hardware
c) peopleware d) software
____5. Which of the following is the fastest? a) mainframes b) microcomputers
c) minicomputers
d) supercomputers
1.1. Introduction
A computer is a machine that performs tasks, such as
calculations or electronic communication, under the
control of a set of instructions called a program.
Programs usually reside within the computer and are
retrieved and processed by the computers
electronics. The program results are stored in or routed
to output devices, such as video display monitors or
printers. Computers perform a wide variety of activities reliably,
accurately, and quickly. Technically speaking it is an automatic high speed,
electronic digital device with internal storage, and is controlled by a stored The Computer
program - a self-directing digital device because its operations are performed within the
system where it measures quantities in discrete or exact numbers.
Page 3 of 88
INPUT
PROCESS
OUTPUT
STORAGE
Page 4 of 88
Process
Storage
Output
Handtop
Page 5 of 88
Tablet PC
Desktop
Notebook
Supercomputers. The fastest, most powerful computer- and the most expensive. Capable
of processing more than 100 trillion instructions in a single second. Weighs more than
100 tons, these computers can store more than 20,000 times the data and information of
an average desktop computer. Applications requiring complex, sophisticated
mathematical calculations use supercomputers. Large scale simulations and applications
in medicine, aerospace, automotive design, online banking, weather forecasting, nuclear
energy research, and petroleum exploration use a supercomputer.
Page 6 of 88
Supercomputer
Page 7 of 88
Page 8 of 88
Page 9 of 88
Page 10 of 88
Page 11 of 88
PC Video Camera
DVD.
DV Camera
0 Digital Video (DV) Camera. Captures and records video digital signals. Most DV cameras
can capture still frames, as well as motion.
0 PC Video Camera a type of digital video camera that enables a home or small business
user to capture video and still images, send e-mail messages with video attachments, add
live images to instant messages, broadcast live images over the Internet, and make video
telephone calls.
Web Cam any video camera that displays its output on a web page. A Web cam attracts
web site visitors by showing images that change regularly.
Video Conferencing A video conference is a meeting between two or more
geographically separated people who use a network or the internet to transmit
audio and video data. To participate in a video conference, you need a video
Page 12 of 88
Handheld Scanner
Wand Reader
RFID tags
OPTICAL READERS
An optical reader is a device that uses a light source to read
characters, marks, and codes and then converts them into
digital data that a computer can process.
0 Optical Mark Recognition(OMR) a technology that reads
hand-drawn marks such as small circles or rectangles. OMR
Magnetic stripe
devices are sometimes called mark sensing device, because
Magstripe reader
a it senses marks on a piece of paper like test questionnaires or blackened areas.
Page 13 of 88
Bar Code
MICR Reader
Page 14 of 88
widely
used
Hand Geometry System. Measures the shape and size of a persons hand.
Voice Verification System. Compares a persons live speech with their stored voice
pattern.
Signature Verification System. Recognizes the shape of your handwritten signature, as
well as measures the pressure exerted and the motion used to write the signature. It
uses a specialized pen and tablet.
Iris Recognition System. A camera is used to read pattern in the iris of the eye. This type
of recognition system are quite expensive and are used by government security
organizations, the military, and financial institutions that deal with highly sensitive data.
Page 15 of 88
Page 16 of 88
LCD Monitors
Plasma Monitors
Page 17 of 88
Page 18 of 88
Impact Printer
Line Printer
Inkjet Printer
Thermal Printer
Page 19 of 88
Speakers
Headsets
Page 20 of 88
Fax Machine
Multifunction Peripheral
Post-Test
Multiple Choice. Write the capital letter of your answer on the space provided.
____1. Given the same computer time, which of the following output device consumes the least
power? a) CRT Monitors b) LCD Monitors c) Plasma Monitors d) Smart Boards
____2. Which of the following can store the most data?
a) 3.5 floppy disk b) cassette tape c) hard disk d) optical disk
____3. Which of the screen standard has the highest resolution?
a) CGA b) EGA c) SVGA d) VGA
____4. The core of a CRT monitor is a(n) ____. a. LCD monitor b. high-definition television c.
active-matrix monitor d. cathode-ray tube
____5. A single device that looks like a copy machine but provides the functionality of a printer,
scanner, copy machine, and perhaps a fax machine is called a ____. a. total printer b.
subwoofer c. multifunction peripheral d. master printer
____6. A(n) ____ boosts low bass sounds. a. subwoofer b. headset c. microphone d. internal
speaker
____7. Sophisticated printers used to produce high-quality drawings such as blueprints, maps,
and circuit diagrams are called ____. a. laser printers b. plotters c. thermal printers d.
line printers
____8. ____ devices display information in one color on a different color background. a.
Unichrome b. Monochrome c. Color d. LCD
____9. LCD monitors are also called ____. a. plotters b. flat panel monitors c. HDTV (highdefinition television) monitors d. gas plasma displays
____10.
Print Orientation where the shorter side of the paper is on the sides. A) portrait b)
landscape
Page 21 of 88
Page 22 of 88
CPU
H ar d D isk D r ive
FAN
PPOWER
O W E CORD
R CO RD
HEAT SINK
System Unit
FLO PPY D RI VE
VIDEO CARD
ZIP DRIV E
MODEM
SOUND CARD
E XT RA CA SE FA N
RIBBON CABLE
RAM
Processor slot
Motherboard
Processors
Page 23 of 88
Page 24 of 88
Approx. # of pages
of text
10
2 or 1,024
220 or 1,048,576
500
30
2 or 1,073,741,824
500,000
40
2 or 1,099,511,627,776 500,000,000
250
260
270
280
1 thousand
1 million
1 billion
1 trillion
1 quadrillion
1 quintillion
1 sextillion
1 septillion
3 Floppy Disk
Page 25 of 88
Disc Format
Read
CD-ROM
Y
CD-R
Y
CD-RW
Y
DVD-ROM
Y
DVD-R, DVD+R
Y
DVD-RW, DVD+RW Y
DVD-RAM
Y
BD-ROM
Y
BD-R, BD+R
Y
BD-RW, BD+RW
Y
BD-RAM
Y
Write Erase
N
N
Y
N
Y
Y
N
N
Y
N
Y
Y
Y
Y
N
N
Y
N
Y
Y
Y
Y
Capacity
650 MB to 1 GB
650 MB to 1 GB
650 MB to 1 GB
4.7 GB to 17 GB
4.7 GB to 17 GB
4.7 GB to 17 GB
4.7 GB to 17 GB
25 GB to 128 GB
25 GB to 128 GB
25 GB to 128 GB
25 GB to 128 GB
Optical Disks
Tape
PC Card
Page 26 of 88
Page 27 of 88
CHAPTER V
DESKTOP FAMILIARIZATION
Guide Questions:
1. List down at least 5 special keys found on the keyboard and explain their uses.
2. What do you think is the main reason why mouse was conceived? Explain your answer.
3. Awareness, Knowledge and Interaction are the three components of computer literacy.
Discuss why these three should be present in you.
Objectives: At the end of the Chapter, the students will be able to:
be familiar with the parts of the mouse and computer keyboard
be knowledgeable about the usage of the mouse and the computer keyboard
be familiar with the Windows Operating System
identify the elements of the Windows Desktop and its components
be aware of the elements of a window
be acquainted with the accessories programs in Windows
Pre-Test:
Multiple Choice. Write the capital letter of your answer on the space provided.
____1. Pictorial representation of files and programs in a GUI programs
a) buttons b) forms c) icon d) menu
____2. Who developed the QWERTY keyboard? a) Christopher Sholes b) Howard Aiken
c) James Qwerty d) Walter Brattain
____3. A standard equipment included by IBM and Apple to computer design for graphic user
interface. a) disk drives
b) keyboard c) mouse
d) optical disk
____4. A type of icon that represents area for stored files such as documents, graphics and
programs.
a) document b) folder
c) original
d) program
____5. A window displayed by the computer used to solicit response from the user.
a) dialog box b) menu bar c) program
d) splash screen
5.1. INTRODUCTION
Familiarization is one vital issue one must consider in mastering computer utilization.
Exposure to the computer environment necessitates the users acquaintance with the
computer. With the advent of GUI(Graphic User Interface), where the screen display is in the
format that enables the user to choose commands, start programs, and see lists of files and
other options by pointing to pictorial representations (icons) and lists of menu items on the
screen by using the GUI device called mouse, computer interaction has been trouble-free as a
result of its user-friendly environment. Most personal computers (PCs) include a keyboard
because it is easy to use and efficient for everyday tasks such as word processing. A mouse is
another input devices that help the user point, select, and move objects on a video display
monitor. The proper use of the computer keyboard and mouse is discussed in this chapter.
Page 28 of 88
5.3. MOUSE
A common pointing device was popularized by its inclusion as standard equipment with
the Apple Macintosh and IBM computers. The basic features of a mouse are a casing with a flat
bottom, designed to be gripped by one hand; one or more buttons at the top; a
multidirectional detection device (usually a ball) at the bottom; and a cable connecting the
mouse to the computer. By moving the mouse on a surface (such as a desk), the user typically
controls an on-screen cursor. A mouse is a relative pointing device because there are no
defined limits to the mouse's movement and because its placement on a surface does not map
directly to a specific screen location. To select items or choose commands on the
screen, the user presses one of the mouse's buttons, producing a mouse click.
LEFT BUTTON
Parts of a Mouse
RIGHT BUTTON
A. Left button
MOUSE
B. Right button
MOUSE PAD
Mouse Operations
A. Point moving the mouse around the mouse pad and the positioning of the
mouse pointer on the text, programs or icons on the monitor. Pointing
Mouse and
its parts
to an an-screen item usually displays a ScreenTip
containing
information about that item.
Page 29 of 88
Windows Desktop
Page 30 of 88
Folder icons
Document icons
Program icons
Original icons
Page 31 of 88
Program window
Document window
Folder window
Types of Windows
Page 32 of 88
Title Bar
Window title
Title Bar
Status Bar
Parts of a Window
The Menu bar. The Menu bar appears just below the Title bar and displays
additional options when you click the menu name. A menu is a group of related
commands or instructions that tells Windows what you want to do
Elements of a Menu
Pull down menu a menu that appears to pull-down from the Menu
bar.
Right-pointing Arrow appears at the side of a command, which
indicates that if you choose the command, another menu will
appear with more menu options
Ellipsis ()
appears after a command to indicate that Windows
needs more information in order to complete the command. To
get that information, Windows displays a dialog box.
Check mark indicates that a menu is currently active.
Note: Besides clicking on the menu name, you can also access menus
by holding down the Alt key and the underlined letter in the
menus name. For example, in most programs the File menu can
be accessed by holding down the Alt and F keys at the same time.
Scroll Bars & Buttons. Use the scroll bars to move around within your
document or window. Click the scroll bars located on the right and bottom
edges of the window to move up, down, left or right.
Page 33 of 88
Notepad
Calculator
Paint
Windows Accessories
Page 34 of 88
CTRL+V
DELETE
CTRL+Z
F1
ALT+SPACEBAR
CTRL+ESC
ALT+TAB
Page 35 of 88
Page 36 of 88
I N T R O D U C T I O N T O V I S U A L BASIC
Guide Questions:
1. Explain how to open a new project.
2. What is the use of the Properties window? Why should it be necessarily displayed?
3. In your own words, describe a form. List at least ten windows elements that uses a form.
Outcomes:
At the end of the Chapter, the students can:
define RAD.
describe and be familiar with the environment of Visual Basic.
identify and use appropriately the different windows in Visual Basic programming.
distinguish the different functions and uses of the control buttons.
Pre-Test:
Multiple Choice. Write the capital letter of your answer on the space provided.
____1. Developers of BASIC : a) Gates and Allen b) Jobs and Wozniak c) Kenemy and Kurtz
d)
Marcos and Arroyo
____2. The process of rapidly creating an application in a graphic user interface program: a) CAD
b) IDE c) RAD d) RAM
____3. Which of the following is not an attribute that can be used to describe a human being? a)
brown eyes b) female
c) talk d) thin
____4. In a procedure oriented languages, the emphasis of a program is on how to accomplish a
task. a) TRUE
b) FALSE
____5. A function key to run a Visual BASIC program: a) F1 b) F2 c) F5 d) F8
6.1. INTRODUCTION
Welcome to Microsoft Visual Basic, the fastest and easiest way to create applications
for Microsoft Windows. Whether you are an experienced professional or brand new to
Windows programming, Visual Basic provides you with a complete set of tools to simplify
rapid application development. The "Visual" part refers to the method used to create the
graphical user interface (GUI). Rather than writing numerous lines of code to describe the
appearance and location of interface elements, you simply add prebuilt objects into place on
screen. If you've ever used a drawing program such as Paint, you already have most of the
skills necessary to create an effective user interface. Beginners can create useful applications
by learning just a few of the keywords, yet the power of the language allows professionals to
accomplish anything that can be accomplished using any other Windows programming
language.
6.2. HISTORY OF VISUAL BASIC
Visual Basic evolved from BASIC (Beginners All-purpose Symbolic Instruction Code).
Basic was developed in the mid 1960s by Professors John Kemeny and Thomas Kurtz of
Darmouth College as a language for writing simple programs. BASICs primary purpose was
to help people learn how to program.
Page 37 of 88
Page 38 of 88
Form
Title bar
Menu bar
Tool bar
Project
Explorer
Window
Sizing
handle
Properties
Window
Form
Layout
Window
Figure shows the IDE after the Standard EXE is selected. The top of the IDE window
(the title bar) displays Project1-Microosoft Visual Basic [design]. The environment contains
various windows, a menu bar and a tool bar.
A Standard EXE project contains the following
windows:
Project1Form1(Form)
Form Layout
Properties-Form1
Project-Project1
Toolbox
Form Window
The Project-Form1 window contains a form named Form1, which is where the
programs Graphical User Interface (GUI) will be displayed. A GUI is the visual portion
of the program(i.e., buttons, label, etc.) this is where the user enters data (called
inputs) to the program and where the program displays its results (called outputs) for
the user to read. We refer the Form1 window simply as the form.
Form Layout Window
The Form Layout window specifies a forms position on the screen at runtime.
It consists of an image representing the screen and the forms relative position on the
screen.
Screen
Form
Properties Window
Form Layout Window
The Properties window displays the properties for a form or a control.
Properties are attributes such as size, position, etc. Like a form, each control type
has its own set of properties. Some properties, like Width and Height, such as, are
common to both forms and controls, while other properties are unique to a form or
a control. Controls often differ in the number and type of properties.
Type of control
Name of control
Selected
property
Selected
property
description
Properties Window
Page 40 of 88
Project name
View Object
Forms folder
Toggle Folders
Forms module
Project Explorer
View Code button displays a window for writing Visual Basic code.
View Object button displays the form.
Toggle Folders button toggles the Forms folder
Toolbox
The toolbox contains controls used to customize forms. Controls are
prepackaged components that you reuse instead of writing them yourself-this helps
you write programs faster.
PictureBox
Pointer
TextBox
Label
CommandButton
Frame
OptionButtonn
CheckBox
ListBox
ComboBox
VScrollBar
HScrollBar
DriveListBox
Timer
DirListBox
FileListBox
Shape
Line
Image
Data
OLE
Toolbox Window
Page 41 of 88
Prefix Description
Used to interact with the controls on the form (I.e., resize them,
move them, etc.). The pointer is not a control.
PictureBox Pic
Label
Lbl
TextBox
Txt
Frame
Fme
Command
Button
cmd
CheckBox
chk
OptionButton opt
ListBox
A ListBox control displays a list of items from which the user can
select one or more.
ComboBox cbo A control that provides a short list of items. A ComboBox control
combines the features of a TextBox control and a ListBox control
users can enter information in the text box portion or select an
item from the list box portion of the control.
HScrollBar hsb A horizontal scrollbar.
VScrollBar vsb A vertical scrollbar
Scroll bars provide easy navigation through a long list of items or a
large amount of information.
Lst
Timer
Page 42 of 88
View
Project
Format
Debug
Page 43 of 88
Tools
Table 2. Menus
Page 44 of 88
Page 45 of 88
Create New
Up one level
Existing Folder
Page 46 of 88
Step1
Steps 2 & 3
Steps 6 & 7
Steps 4 & 5
Saving Procedure
When you have completed all the files for a project, you can convert the project into an
executable file (.exe): From the File menu, choose the Make project.exe command.
Page 47 of 88
Page 48 of 88
Page 49 of 88
d) hide
7.1. INTRODUCTION
In Visual Basic an object is a combination of code and data that can be treated as a unit.
An object can be a piece of an application, like a control (e.g. textbox, command button, label,
etc.) or a form. An entire application can also be an object. Most of the programming tasks in
visual basic is done through working with the objects.
Visual Basic objects have their own properties, methods and events. Properties can be
thought of as an object's attributes, methods as its actions, and events as its responses.
An everyday object like a child's helium balloon also has properties, methods and events.
A balloon's properties include visible attributes such as its height, diameter and color. Other
properties describe its state (inflated or not inflated), or attributes that aren't visible, such as
its age. By definition, all balloons have these properties; the settings of these properties may
differ from one balloon to another.
A balloon also has inherent methods or actions that it might perform. It has an inflate
method (the action of filling it with helium), a deflate method (expelling its contents) and a rise
method (if you were to let go of it). Again, all balloons are capable of these methods.
Balloons also have predefined responses to certain external events. For instance, a
balloon would respond to the event of being punctured by deflating itself, or to the event of
being released by rising into the air.
Page 50 of 88
If you were able to program a balloon, the Visual Basic code might look like the following.
To set the balloon's properties:
Balloon.Color = Red
Balloon.Diameter = 10
Balloon.Inflated = True
Note the syntax of the code the object (Balloon), followed by the property (.Color),
followed by the assignment of the value (Red). You could change the color of the balloon from
code by repeating this statement and substituting a different value. Properties can also be set
in the Properties window while you are designing your application.
A balloon's methods are invoked like this:
Balloon.Inflate
Balloon.Deflate
Balloon.Rise 5
The syntax is similar to the property the object (a noun) followed by the method (a
verb). In the third example, there is an additional item, called an argument, which denotes the
distance to rise. Some methods will have one or more arguments to further describe the action
to be performed.
The balloon might respond to an event as follows:
Sub Balloon_Puncture()
Balloon.Deflate
Balloon.MakeNoise "Bang"
Balloon.Inflated = False
Balloon.Diameter = 1
End Sub
In this case, the code describes the balloon's behavior when a puncture event occurs:
invoke the Deflate method, then invoke the MakeNoise method with an argument of "Bang"
(the type of noise to make). Since the balloon is no longer inflated, the Inflated property is set
to False and the Diameter property is set to a new value.
While you can't actually program a balloon, you can program a Visual Basic form or
control. As the programmer, you are in control. You decide which properties should be
changed, methods invoked or events responded to in order to achieve the desired appearance
and behavior.
Form objects are the basic building blocks of a Visual Basic application, the actual
windows with which a user interacts when he runs the application. Forms have their own
properties, events, and methods with which you can control their appearance and behavior.
Page 51 of 88
Forms and controls have their own properties, events, and methods
The work with forms and controls, set their properties, and write code for their events at
design time, which is any time you're building an application in the Visual Basic environment.
Run time is any time you are actually running the application and interacting with the
application as the user would.
Suggestions and Reminders about Visual BASIC Programming
1. Plan ahead
2. Think like a user
3. Think components
4. Learn by doing
5. Learn from Visual BASIC programs
7.2. WRITING BASIC CODE
When you're happy with the way your program looks, the next step involves writing
BASIC commands (also known as code) to make your program actually work.
The whole purpose of Visual Basic code is to tell objects on a form what to do when the
user does something. For example, if the user clicks on an OK or Cancel command button,
nothing happens unless you've written BASIC commands to tell your computer exactly what to
do.
Any time a user presses a key, moves the mouse, or clicks the mouse button, it's called an
event. Whenever an event occurs, your BASIC commands tell the computer, "Something just
happened. Let's do something about it!"
Essentially, writing a Visual Basic program means drawing your user interface and then
writing BASIC code to make it work. If you can handle these two steps without losing your
mind, you can start writing your very own programs using Visual Basic.
7.3. EVENT PROCEDURES
Whenever the user takes any action, such as clicking the mouse, pressing a key, passing
out on the keyboard, or putting a bullet through the monitor, the action is called an event. The
moment an event occurs, Visual Basic looks for BASIC code to tell the program what to do. The
BASIC code that responds to a specific event is called an event procedure.
A single Visual Basic program can consist of several thousand event procedures. If you
have that many, however, you either have a tremendously complicated program or you're an
incredibly incompetent programmer.
With so many possible events and so many possible event procedures in a single
program, how does Visual Basic know which event procedure to use?
Page 52 of 88
Page 53 of 88
Page 54 of 88
keywords
control name
input area
Fig. 77. Click Event Procedure
Page 55 of 88
Page 56 of 88
Page 57 of 88
B A S I C E L E M E N T S O F A V I S U A L BASIC P R O G R A M
Guide Questions:
1. What are data types and variables? What are the important facts a programmer always
should remember when using them in the program?
2. What is/are the difference of the integer division operator (\) and the modulus operator
(mod)?
3. Convert the Pythagorean theorem formula to programming formula.
Outcomes:
At the end of the Chapter, the students can:
understand the basic elements of a Visual BASIC program
write simple programs in Visual BASIC
be familiar with the use of fundamental data types
use arithmetic operators
understand the precedence of arithmetic operators
Pre-Test.
Multiple Choice. Write the capital letter of your answer on the space provided.
____1. Which of the following is a valid declaration?
a) Dim x as integer b) Private x as float c) Sub x as long d) Variable x as double
____2. A variable declared at module level can be available in:
a) all modules b) all programs
c) current procedure d) all forms
____3. Which is a valid variable? a)As b)intarea
c) 2>1
d) dim
____4. A data type assigned to undeclared variables: a) byte b) date c)long d) variant
____5. Which of the following operators will be the last to be evaluated?
a) \ b) ^ c) +
d) *
8.1. INTRODUCTION
The Visual BASIC language facilitates a structured and disciplined approach to
computer program design. When writing a program, it is equally essential to understand
the types of building blocks that are available and to employ proven program construction
principles. In this chapter, we introduce the Visual BASIC programming concepts and
illustrate many of its important features like memory concepts, arithmetic operators,
decision-making or comparison operators, and data types used in Visual BASIC
programming.
8.2. VARIABLES, CONSTANT, DATA TYPES AND OPERATORS
In Visual Basic, you use variables to temporarily store values during the execution of
an application. Variables have a name (the word you use to refer to the value the variable
contains) and a data type (which determines the kind of data the variable can store).
You use assignment statements to perform calculations and assign the result to a
variable:
ApplesSold = 10
' The value 10 is passed to the variable.
ApplesSold = ApplesSold + 1 ' The variable is incremented.
Page 58 of 88
Page 59 of 88
or
Static intPermanent As Integer
Values in local variables declared with Static exist the entire time your application is
running while variables declared with Dim exist only as long as the procedure is executing.
Local variables are a good choice for any kind of temporary calculation. For example,
you can create a dozen different procedures containing a variable called intTemp. As long as
each intTemp is declared as a local variable, each procedure recognizes only its own version
of intTemp. Any one procedure can alter the value in its local intTemp without affecting
intTemp variables in other procedures.
8.4. CONSTANT
A constant is a meaningful name that takes the place of a number or string that
does not change. Although a constant somewhat resembles a variable, you can't modify a
constant or assign a new value to it as you can to a variable. There are two sources for
constants:
Intrinsic or system-defined constants are provided by applications and controls.
Visual Basic constants are listed in the Visual Basic (VB) and Visual Basic for
applications (VBA) object libraries in the Object Browser. Other applications that
provide object libraries, such as Microsoft Excel and Microsoft Project, also provide
a list of constants you can use with their objects, methods, and properties.
Symbolic or user-defined constants are declared using the Const statement.
The syntax for declaring a constant is:
Const constantname[As type] = expression
example:
Const conPi = 3.14159265358979
Const conMaxPlanets As Integer = 9
Page 60 of 88
Pre- fix
Stores
Memory
Required
Range of values
Boolean
bln
Logical Values
2 bytes
True or False
Byte
Currency
byt
cur
1 byte
8 bytes
0 to 255
-922337203685477.5808 to
922337203685477.5808
Date
dte
8 bytes
Double
dbl
Integer
Long
Object
int
lng
obj
Single
sng
1 January 100 to 31
December 9999
0:00:00 to 23:59:59
-1.79769313486232E308 to
4.94065645841247E-324
1.79769313486232E308 to
4.94065645841247E-324
-32768 to 32767
-2147483648 to
2147483647
Any Object type
String
Variant
str
vnt
Binary values
Numbers with
up to 15 digits to
the left of the
decimal and 4
digits to the
right
Date and time
information
Floating-point
numbers
Whole numbers
Whole numbers
Any object
reference
Floating-point
numbers
Text Information
Any other data
types
8 bytes
2 bytes
4 bytes
4 bytes
4 bytes
10+
bytes
16 bytes
-3.402823E38 to
1.401298E-45
3.402823E38 to 1.401298E45
0 to ~2000000000
characters
Any value within the range
listed above
Before using a non-Variant variable, you must use the Private, Public, Dim or Static
statement to declare it As type. For example, the following statements declare an Integer,
Double, String, and Currency type, respectively:
Private H As Integer
Dim Amt As Double
Static YourName As String
Public BillsPaid As Currency
Page 61 of 88
Arithmetic Operators
Exponentiation (^)
Second
Third
Negation (-)
Multiplication and division (*,
/)
Fourth
Fifth
Sixth
Evaluation
Used to raise a number to the
power of an exponent
Ex. 2^3 = 8
Makes a number negative
Used to multiply and divide
numbers
Ex. 2 * 4 = 8,
8/4=2
Used to divide two numbers and
return an integer result
Ex. 10 \ 4 = 2
Used to divide two numbers and
return the remainder
Ex. 5 mod 2 = 1
Used to add and subtract two
numbers.
Used to concatenate strings
Ex. Hello & world this will
result to Hello world
Page 62 of 88
Page 63 of 88
Page 64 of 88
Example
- (10 is equal to 10)
- ( 1 is equal to 5 )
- (10 is not equal to 10)
- ( 1 is not equal to 5 )
- (10 is less than 10)
- ( 1 is less than 5 )
- (10 is greater than 10)
- ( 1 is greater than 5 )
- (10 is less than or equal to 10)
- ( 1 is less than or equal to 5 )
- (10 is greater than or equal to 10)
- ( 1 is greater than or equal to 5 )
Boolean
Value
TRUE
FALSE
FALSE
TRUE
FALSE
TRUE
FALSE
FALSE
TRUE
TRUE
TRUE
FALSE
Page 65 of 88
Notice that the single-line form of If...Then does not use an End If statement. If
you want to execute more than one line of code when condition is True, you must
use the multiple-line block If...Then...End If syntax.
If x < 10 Then
Print Hello
cmdOk.Enabled = False
End If
If -Then-Else
Page 66 of 88
Page 67 of 88
Notice that the Select Case structure evaluates an expression once at the top of
the structure. In contrast, the If...Then...Else structure can evaluate a different
expression for each ElseIf statement. You can replace an If...Then...Else structure with a
Select Case structure only if the If statement and each ElseIf statement evaluates the
same expression.
Post-Test.
Multiple Choice. Write the capital letter of your answer on the space provided.
______1. Evaluate the expression: 4 > 6 OR 10 < 2*6
a) True b) False
______2. Evaluate the expression: 7 >= 3+4 OR 6 <4 AND 2 < 5 a) True b) False
Use the following information: x=5, y=3, z=2, A=true and B=false
______3. Evaluate the expression: X*Z > X*Y AND A
a) True b) False
______4. Evaluate the expression: X*Z < X*Y OR A
a) True b) False
______5. Evaluate the expression: A AND B
a) True b) False
______6. Evaluate the expression: X*Y > Y^Z
a) True b) False
______7. Evaluate the expression: X*Y>Y^Z AND A OR B
a) True b) False
______8. A function that returns the sign of s number a) Atn b) Rnd C)Sgn d)Val
______9. ABS(-210-5) is equal to a) -215 b)-205 c) 205 d)215
______10. RIGHT$(Unbelievable, 4) is a) Unbel
b) liev c) live d) able
Programming Exercise.
1. Prepare a program that requests the cost and revenue for a companys business venture
and displays Break Even if the cost and revenue are equal; otherwise display the profit
or loss.
2. Prepare a program that will determine if the first number entered by the user is less than,
greater than, or equal to the second number entered.
3. Develop a program that would determine if the number entered by the user is POSITIVE,
NEGATIVE, or ZERO.
4. Revise programming exercise Set A # 3, create a condition when there will be no roots
available for the entered data. (In case where imaginary number will be one of the roots.)
5. Create a program that would tell the user if the numbered entered by the user is ODD or
EVEN.
6. Create a program for a Cartesian Plane. Two numbers will be entered by the user as data
for X and Y. After clicking a button, the program will display its location on the Cartesian
Plane.
Page 68 of 88
LABORATORY
ACTIVITIES
Page 69 of 88
Page 70 of 88
Click
or press Enter on your keyboard.
Close the WordPad window and other opened windows.
3a
e. Click
or
press Enter on your
keyboard.
f. Close the Paint
window and other opened windows.
V. Shut-Down Procedure
a. Click Start
Shut-down
Yes/OK
b. Wait until the message It is now safe to turn-off the computer. is displayed
before turning the power off.
Page 71 of 88
B. Start
Programs
Accessories
WordPad
Format
Tab
___________________ - ____
___________________ - ____
___________________ - ____
Page 72 of 88
___________________ - ____
___________________ - ____
___________________ - ____
___________________ - ____
D. Start
Programs
Accessories
Paint
Image
Flip Rotate
___________________ - ____
___________________ - ____
E. Start
Programs
Accessories
Notepad
Edit
Set Font
___________________ - ____
___________________ - ____
___________________ - ____
___________________ - ____
___________________ - ____
___________________ - ____
F. Start
Programs
Accessories
Paint
Image
Stretch and Skew
___________________ - ____
___________________ - ____
___________________ - ____
Page 73 of 88
Page 74 of 88
Alignment 1.
2.B
3.
4.
5.
6.
7.
8.
9.
Caption 10.
11. A
12.
13.
14.
15.
16.
17.
18.
Enabled 19.
20. B
21.
22.
23.
24.
25.
26.
27.
FillColor 28.
29. B
30.
31.
32.
33.
34.
35.
36.
FillStyle 37.
38. B
39.
40.
41.
42.
43.
44.
45.
Font
46.
47. C
48.
49.
50.
51.
52.
53.
54.
ForeColor 55.
56. B
57.
58.
59.
60.
61.
62.
63.
Icon
64.
65. C
66.
67.
68.
69.
70.
71.
72.
Interval 73.
74. D
75.
76.
77.
78.
79.
80.
81.
Left
82.
83. A
84.
85.
86.
87.
88.
89.
90.
Name
91.
92. A
93.
94.
95.
96.
97.
98.
99.
Picture
100. 101. D 102. 103. 104. 105. 106. 107. 108.
TabIndex 109. 110. D 111. 112. 113. 114. 115. 116. 117.
Text
118. 119. D 120. 121. 122. 123. 124. 125. 126.
Value
127. 128. D 129. 130. 131. 132. 133. 134. 135.
Task 4: After accomplishing the above table. Save the form and the project
Name of the folder (for step 2):
Activity1
Filename for the form (for step 4):
frmForm1.frm
Filename for the project ( for step 6):
Activity1.vbp.
Task 5: Close the project by clicking on the close button.
Filing
Page 75 of 88
Object
Property
Property Setting
Form
Folder name:
Form name:
Project name:
Activity2
frmAct2.frm
Activity2.vbp
Name
FrmAct2
Caption
Sample 1
Backcolor Black
BorderStyle1-Fixed Single
label
Name
lblQ
Caption
Question:
BackStyle 0 -Transparent
Font
Arial, 16 pts
ForeColor White
Textbox
Name
txtQuestion
Alignment 2-Center
Comic Sans MS, 16
Font
pts
Processed data is
Text
called information.
Multiline True
Command Name
cmdTrue
Button
Caption
TRUE
Command Name
cmdFalse
Button
Caption
FALSE
Page 76 of 88
Property
Setting
Name FrmAct3
Caption Sample 2
Name txtDisplay
Text
Visual BASIC
Name fmeColors
Caption Text Color
Name OptBlack
Caption Black
Value True
Name OptRed
Object Property
Form
Textbox
Frame
Option
Button
Task 4: Run the program
Task 5: Save the form and the project
Folder name:
Form name:
Project name:
Activity3
frmAct3.frm
Activity3.vbp
Option
Button
Caption Red
Option
Name
Button
Caption
Command Name
Button
Caption
Command Name
Button
Caption
OptBlue
Blue
CmdApply
&Apply
CmdExit
&Exit
B. Layout 3.
On your own, create a form with the following objects.
Folder name:
Form name:
Project name:
Activity4
frmATM.frm
Activity4.vbp
Page 77 of 88
Property
Property Settings
Form
Name
Caption
Name
Caption
Name
Caption
FrmAct4
Printing Text on the Form
cmdPrint
Print
CmdExit
Exit
Button
Button
Task 4: Supply the codes
Page 78 of 88
b
Activity2
Activity2
Page 79 of 88
Object Property
Form
Option
Button
Option
Button
Option
Button
Label
Button
Task 5: Supply the codes to make the program work
Button
Button
Name
Caption
Name
Caption
Name
Caption
Name
Caption
Name
Caption
Alignment
Font
Name
Caption
Name
Caption
Enabled
Name
Caption
Property Settings
frmAct6
Font Color
optRed
RED
optBlue
BLUE
optWhite
White
lblColor
WIT
2-center
Times New
Roman,64pts
cmdHide
HIDE
cmdAppear
APPEAR
False
cmdExit
Exit
Page 80 of 88
Object
Form
Name
Caption
Label
Font
Caption
Label
Font
Caption
Label
Font
Caption
Textbox
Name
Textbox
Name
Textbox
Name
List Box
Name
Checkbox Name
Caption
Checkbox Name
Caption
Checkbox Name
Caption
Enabled
Command Name
Button
Caption
Command Name
Button
Caption
Command Name
Button
Caption
frmAct7
List of Names
Arial, Bold, 10 pts
First Name
Arial, Bold, 10 pts
Last Name
Arial, Bold, 10 pts
Age
txtFN
txtLN
txtAge
LstTable
chkBold
Bold
chkItalic
Italic
chkRegular
Regular
False
cmdAdd
&Add to List
cmdClear
Clear
cmdExit
Exit
Page 81 of 88
Try to use the CLEAR button and enter new set of names
Page 82 of 88
Object
Property
Property Settings
Form
Name
Caption
Font
Caption
Font
Caption
Name
Caption
Name
Caption
Name
Alignment
Name
Alignment
Name
Caption
Name
Caption
frmAct8
Sum and Product
Arial, Bold, 14 pts
First number
Arial, Bold, 14 pts
Second Number
Lblsum
SUM =
lblProd
PRODUCT =
txtFirst
Center
txtSec
Center
cmdCompute
COMPUTE
cmdExit
EXIT
Label
Label
Label
Task 4: Supply the codes to make the program work
Label
Textbox
Textbox
Command
Button
Command
Button
Page 83 of 88
Page 84 of 88
Object
Property
Property Settings
Form
Name
Caption
Name
Alignment
Name
Alignment
Name
Alignment
Name
Caption
Name
Caption
frmAct9
Average of 3 Exams
txtMT
Center
txtPF
Center
txtF
Center
cmdComp
COMPUTE
lblAve
AVERAGE =
Textbox
Textbox
Textbox
Command
Button
Label
Task 5: Run the program and enter values to check the computations
Page 85 of 88
Name
Border
Style
lblDisplay
1-Fixed Single
Task#3. Run the program and enter different values to check the output
Task#4. Save the program
using the same filename
Page 86 of 88
Label
Name
lblGrade
Forecolor Yellow
Border
1-Fixed Single
Style
Task#3. Run the program and enter different values to check the output. Save
Page 87 of 88
References:
Capron, L., Johnson, J.A. Capron, Computers, Tools for an Information Age, 7th Ed., 2009, The
Benjamin/Cummings Publishing Company, Inc.
Kenneth C. Laudon, Jane P. Laudon, Jane Price Laudon, Carol Guercio Traver, Information
Technology: Concepts and Issues (2nd edition), 1997, Course Technology
Gary B. Shelly, Thomas J. Cashman, Misty E. Vermaat, Discovering Computers 2011, Livingin a
DIgital World, 2010, Thompson Course Technology.
Zak, Diane, Programming with Microsoft Visual Basic 6.0, 1999,Course Technology
Dietel, H.M., Dietel, P.J. and Nieto, T.R., Visual Basic 6 How to Program, 1999, Prentice-Hall
Ken Getz & Mike Gilbert, Visual Basic Language Developers Handbook, 2000, SYBEX
MSDN Library Visual BASIC 6.0
77
Page 88 of 88