SlideShare une entreprise Scribd logo
1  sur  48
Addison Wesley
is an imprint of
© 2011 Pearson Addison-Wesley. All rights reserved.
CISC 181 – Principles of Information Systems
San Diego Mesa College
Prof. George Bonilla
Chapter 1
Introduction to Programming and Visual Basic
Addison Wesley
is an imprint of
© 2011 Pearson Addison-Wesley. All rights reserved.
Section 1.1
COMPUTER SYSTEMS: HARDWARE
AND SOFTWARE
Computer systems consist of similar hardware devices and hardware
components. This section provides an overview of computer
hardware and software organization.
Copyright © 2011 Pearson Addison-Wesley
Computer Hardware
• Refers to the physical components
• Not one device but a system of many devices
• Major types of components include:
– Central Processing Unit
– Main memory
– Secondary storage devices
– Input devices
– Output devices
Chapter 1 - Slide 3
Copyright © 2011 Pearson Addison-Wesley
Organization of a Computer System
Chapter 1 - Slide 4
Copyright © 2011 Pearson Addison-Wesley
The CPU
• Fetches instructions from main memory
• Carries out the operations commanded by the
instructions
• Each instruction produces some outcome
• CPU gets instructions from a program
• A program is an entire sequence of instructions
• Instructions are stored as binary numbers
• Binary number - a sequence of 1’s and 0’s
Chapter 1 - Slide 5
Copyright © 2011 Pearson Addison-Wesley
Main Memory
• Commonly known as random access memory,
or just RAM
• Holds instructions and data needed for
programs that are currently running
• RAM is usually a volatile type of memory
• Contents are lost when power is turned off
• Used as temporary storage
Chapter 1 - Slide 6
Copyright © 2011 Pearson Addison-Wesley
Secondary Storage
• A nonvolatile storage medium
• Contents retained while power is off
• Hard disk drives are most common
• Records data magnetically on a circular disk
• Provides fast access to large amounts of data
• Optical devices store data on CD’s as pits
• USB flash memory devices
• High capacity device plugs into USB port
• Portable, reliable, and fits easily in a pocket
Chapter 1 - Slide 7
Copyright © 2011 Pearson Addison-Wesley
Input Devices
• Any type of device that provides data to a
computer from the outside world
• For example:
– Keyboard
– Mouse
– Scanner
Chapter 1 - Slide 8
Copyright © 2011 Pearson Addison-Wesley
Output Devices
• Any type of device that provides data from a
computer to the outside world
• Examples of output data:
• A printed report
• An image such as a picture
• A sound
• Common output devices include:
• Monitor (display screen)
• Printer
Chapter 1 - Slide 9
Copyright © 2011 Pearson Addison-Wesley
Software
• The programs that run on a computer
• Two major categories
– Operating systems
• Controls the processes within the computer
• Manages the computer's hardware devices
– Application Software
• Solve problems or perform tasks needed by users
• Examples include word processing, spreadsheets, games,
Internet browsers, playing music, etc)
• Each program is referred to as an application
• This book develops applications in Visual Basic
Chapter 1 - Slide 10
Addison Wesley
is an imprint of
© 2011 Pearson Addison-Wesley. All rights reserved.
Section 1.2
PROGRAMS AND PROGRAMMING
LANGUAGES
A program is a set of instructions a computer follows in order to
perform a task. A programming language is a special language used
to write computer programs.
Copyright © 2011 Pearson Addison-Wesley
What is a Program?
• Computers can only follow instructions
• A computer program is a set of instructions on
how to solve a problem or perform a task
• In order for a computer to compute
someone’s gross pay, we must tell it to
perform the steps on the following slide
Chapter 1 - Slide 12
Copyright © 2011 Pearson Addison-Wesley
Computing Gross Pay
1. Display message: "How many hours did you work?"
2. Allow user to enter number of hours worked
3. Store the number the user enters in memory
4. Display message: "How much are you paid per hour?"
5. Allow the user to enter an hourly pay rate
6. Store the number the user enters in memory
7. Multiply hours worked by pay rate and store the
result in memory
8. Display a message with the result of the previous step
This well-defined, ordered set of steps for solving a
problem is called an algorithm
Chapter 1 - Slide 13
Copyright © 2011 Pearson Addison-Wesley
States and Transitions
Memory snapshots show states of the program
3. Store hours worked in memory
6. Store hourly pay rate in memory
7. Multiply hours worked by pay rate
and store amount earned in memory
Program Starting State
hours worked ??
hourly pay rate ??
amount earned ??
Snapshot after Step 3
hours worked 20
hourly pay rate ??
amount earned ??
Snapshot after Step 6
hours worked 20
hourly pay rate 25
amount earned ??
Snapshot after Step 7
hours worked 20
hourly pay rate 25
amount earned 500
Chapter 1 - Slide 14
Copyright © 2011 Pearson Addison-Wesley
Programming Languages
• The steps in our algorithm must be stated in a
form the computer understands
• The CPU processes instructions as a series of
1’s and 0’s called machine language
• This is a tedious and difficult format for people
• Instead, programming languages allow us to
use words instead of numbers
• Software converts the programming language
statements to machine language
Chapter 1 - Slide 15
Copyright © 2011 Pearson Addison-Wesley
Common Programming Languages
• Visual Basic
• Python
• JavaScript
• Java
• C#
• C
• C++
• PHP
• Visual Basic is not just a programming language
• It’s a programming environment with tools to:
– Create screen elements
– Write programming language statements
Chapter 1 - Slide 16
Copyright © 2011 Pearson Addison-Wesley
What is a Program Made Of?
• Keywords (Reserved Words)
– Words with special meaning that make up a high-level
programming language, cannot be used for any other purpose
• Operators
– Special symbols that perform various operations on data
• Variables
– Used to store data in memory, named by the programmer
• Syntax
– Set of rules
– Similar to the syntax (rules) of a spoken language, such as
English, but must be strictly followed
– If even a single syntax error appears in a program, it will not
compile or execute
Chapter 1 - Slide 17
Copyright © 2011 Pearson Addison-Wesley
What is a Program Made Of?
• Statements
– Instructions made up of keywords, variables, and
operators.
• Procedures
– Set of programming statements that perform a
specific task
• Comments (Remarks)
– Ignored when the program runs, help human reader
understand the purpose of programming statements
– In Visual Basic, any statement that begins with an
apostrophe (')
Chapter 1 - Slide 18
Copyright © 2011 Pearson Addison-Wesley
Methods of Programming
• Procedural
– Constructed as a set of procedures
(operational, functional units)
– Each procedure is a set of instructions
– The Gross Pay computation is a procedure
• Object-Oriented
– Uses real-world objects such as students, transcripts,
and courses
– Objects have data elements called attributes
– Objects also perform actions
Chapter 1 - Slide 19
Copyright © 2011 Pearson Addison-Wesley
Example of an Object
• This is a Visual Basic
GUI object called a form
• Contains data and actions
• Data, such as Hourly Pay
Rate, is a text property
that determines the
appearance of form objects
• Actions, such as Calculate Gross Pay, is a method
that determines how the form reacts
• A form is an object that contains other objects
such as buttons, text boxes, and labels
Chapter 1 - Slide 20
Copyright © 2011 Pearson Addison-Wesley
Example of an Object
• Form elements are
objects called controls
• This form has:
– Two TextBox controls
– Four Label controls
– Two Button controls
• The value displayed by
a control is held in the text property of the control
• Left button text property is Calculate Gross Pay
• Buttons have methods attached to click events
Chapter 1 - Slide 21
Copyright © 2011 Pearson Addison-Wesley
Event Driven Programming: Events
• The GUI environment is event-driven
• An event is an action that takes place within a
program
– Clicking a button (a Click event)
– Keying in a TextBox (a TextChanged event)
• Visual Basic controls are capable of detecting
many, many events
• A program can respond to an event if the
programmer writes an event procedure
Chapter 1 - Slide 22
Addison Wesley
is an imprint of
© 2011 Pearson Addison-Wesley. All rights reserved.
Section 1.3
MORE ABOUT CONTROLS AND
PROGRAMMING
As a Visual Basic programmer, you must design and create an
application’s GUI elements (forms and other controls) and the
programming statements that respond to and/or perform actions
(event handlers).
Copyright © 2011 Pearson Addison-Wesley
Visual Basic Controls
• As a Windows user you’re already familiar with
many Visual Basic controls:
– Label - displays text the user cannot change
– TextBox - allows the user to enter text
– Button – performs an action when clicked
– RadioButton - A round button that is selected or
deselected with a mouse click
– CheckBox – A box that is checked or unchecked with a
mouse click
– Form - A window that contains these controls
• Tutorial 1-3 demonstrates these controls
Chapter 1 - Slide 24
Copyright © 2011 Pearson Addison-Wesley
Tutorial 1-3, Visual Basic Controls
Chapter 1 - Slide 25
Copyright © 2011 Pearson Addison-Wesley
The Name Property
• All controls have properties
• Each property has a value (or values)
• Not all properties deal with appearance
• The name property establishes a means for
the program to refer to that control
• Controls are assigned relatively meaningless
names when created
• Programmers usually change these names to
something more meaningful
Chapter 1 - Slide 26
Copyright © 2011 Pearson Addison-Wesley
Examples of Names
• The Label controls use the default names (Label1, etc.)
• Text boxes, buttons, and the Gross Pay label play an active role in
the program and have been changed
btnCalcGrossPay btnClose
txtHoursWorked
txtPayRate
lblGrossPay
Label1
Label2
Label3
Form1
Chapter 1 - Slide 27
Copyright © 2011 Pearson Addison-Wesley
Naming Conventions
• Control names must start with a letter
• Remaining characters may be letters, digits, or
underscore
• 1st 3 lowercase letters indicate the type of
control
– txt… for Text Boxes
– lbl… for Labels
– btn… for Buttons
• After that, capitalize the first letter of each word
• txtHoursWorked is clearer than txthoursworked
Chapter 1 - Slide 28
Addison Wesley
is an imprint of
© 2011 Pearson Addison-Wesley. All rights reserved.
Section 1.4
THE PROGRAMMING PROCESS
The programming process consists of several steps, which include
designing, creating, testing, and debugging activities.
Copyright © 2011 Pearson Addison-Wesley
Step 1 of Developing an Application
• Clearly define what the program is to do
• For example, the Wage Calculator program:
– Purpose: To calculate the user’s gross pay
– Input: Number of hours worked, hourly pay rate
– Process: Multiply number of hours worked by
hourly pay rate (result is the user’s gross pay)
– Output: Display a message indicating the user’s
gross pay
Chapter 1 - Slide 30
Copyright © 2011 Pearson Addison-Wesley
Step 2 of Developing an Application
• Visualize the application running on the
computer and design its user interface
Chapter 1 - Slide 31
Copyright © 2011 Pearson Addison-Wesley
Step 3 of Developing an Application
• Determine the controls needed
Type Name Description
TextBox txtHoursWorked Allows the user to enter the number of hours worked.
TextBox txtPayRate Allows the user to enter the hourly pay rate
Label lblGrossPay Displays the gross pay, after the btnCalcGrossPay
button has been clicked
Button btnCalcGrossPay When clicked, multiplies the number of hours worked
by the hourly pay rate
Button btnClose When clicked, terminates the application
Label (default) Description for Number of Hours Worked TextBox
Label (default) Description for Hourly Pay Rate TextBox
Label (default) Description for Gross Pay Earned Label
Form (default) A form to hold these controls
Chapter 1 - Slide 32
Copyright © 2011 Pearson Addison-Wesley
Step 4 of Developing an Application
• Define the values of each control’s relevant
properties
Control Type Control Name Text
Form (Default) "Wage Calculator"
Label (Default) "Number of Hours Worked"
Label (Default) "Hourly Pay Rate"
Label (Default) "Gross Pay Earned"
Label lblGrossPay "$0.00"
TextBox txtHoursWorked ""
TextBox txtPayRate ""
Button btnCalcGrossPay "Calculate Gross Pay"
Button btnClose "Close"
Chapter 1 - Slide 33
Copyright © 2011 Pearson Addison-Wesley
Step 5 of Developing an Application
• Determine the event handlers and other code
needed for each control
Method Description
btnCalcGrossPay_Click Multiplies hours worked by hourly pay rate
These values are entered into the
txtHoursWorked and txtPayRate TextBoxes
Result is stored in lblGrossPay Text property
btnClose_Click Terminates the application
Chapter 1 - Slide 34
Copyright © 2011 Pearson Addison-Wesley
Step 6 of Developing an Application
• Create a flowchart or pseudocode version of
the code
– A flowchart is a diagram that graphically depicts the flow
of a method
– Pseudocode is a cross between human language and a
programming language
Chapter 1 - Slide 35
Copyright © 2011 Pearson Addison-Wesley
Step 7 of Developing an Application
• Check the code for errors:
– Read the flowchart and/or pseudocode
– Step through each operation as though you are
the computer
– Use a piece of paper to jot down the values of
variables and properties as they change
– Verify that the expected results are achieved
Chapter 1 - Slide 36
Copyright © 2011 Pearson Addison-Wesley
Step 8 of Developing an Application
• Use Visual Basic to create the forms and other
controls identified in step 3
– This is the first use of Visual Basic, all of the
previous steps have just been on paper
– In this step you develop the portion of the
application the user will see
Chapter 1 - Slide 37
Copyright © 2011 Pearson Addison-Wesley
Step 9 of Developing an Application
• Use the flowcharts or pseudocode from step 6
to write the actual code
– This is the second step on the computer
– In this step you develop the methods behind the
click event for each button
– Unlike the form developed on step 8, this portion
of the application is invisible to the user
Chapter 1 - Slide 38
Copyright © 2011 Pearson Addison-Wesley
Step 10 of Developing an Application
• Attempt to run the application - find syntax
errors
– Correct any syntax errors found
– Syntax errors are the incorrect use of an element
of the programming language
– Repeat this step as many times as needed
– All syntax errors must be removed before Visual
Basic will create a program that actually runs
Chapter 1 - Slide 39
Copyright © 2011 Pearson Addison-Wesley
Step 11 of Developing an Application
• Run the application using test data as input
– Run the program with a variety of test data
– Check the results to be sure that they are correct
– Incorrect results are referred to as a runtime error
– Correct any runtime errors found
– Repeat this step as many times as necessary
Chapter 1 - Slide 40
Addison Wesley
is an imprint of
© 2011 Pearson Addison-Wesley. All rights reserved.
Section 1.5
VISUAL STUDIO AND VISUAL BASIC EXPRESS
EDITION (THE VISUAL BASIC ENVIRONMENT)
Visual Studio and Visual Basic Express Edition consist of tools that
you use to build Visual Basic applications. The first step in using
Visual Basic is learning about these tools.
Copyright © 2011 Pearson Addison-Wesley
The Visual Studio IDE
• Visual Studio is an integrated development
environment, often abbreviated as IDE
– Provides everything needed to create, test, and
debug software including:
• The Visual Basic language
• Form design tools to create the user interface
• Debugging tools to help find and correct programming
errors [ Adm. Grace Hopper-1947; Thomas Edison-1878 ]
Chapter 1 - Slide 42
Copyright © 2011 Pearson Addison-Wesley
The Visual Studio IDE
• Visual Studio is an integrated development
environment, often abbreviated as IDE
– Provides everything needed to create, test, and
debug software including:
• The Visual Basic language
• Form design tools to create the user interface
• Debugging tools to help find and correct programming
errors [ Adm. Grace Hopper-1947; Thomas Edison-1878 ]
• Visual Studio supports other languages beside
Visual Basic such as C++ and C#
Chapter 1 - Slide 43
Copyright © 2011 Pearson Addison-Wesley
The Visual Basic Environment
• Tutorial 1-4 introduces elements of the IDE:
– Customizing the IDE
• Design window –
a place to design and
create a form
• Solution Explorer
window – shows files
in the solution
• Properties window –
modify properties of
an object
Chapter 1 - Slide 44
Copyright © 2011 Pearson Addison-Wesley
The Visual Basic Environment
• Tutorial 1-4 introduces elements of the IDE:
– Customizing the IDE
• Dynamic Help
window – a handy
reference tool
• Toolbar –
contains icons for
frequently used
functions
• Toolbox window – objects used in form design
• Tooltips – a short description of button’s purpose
Chapter 1 - Slide 45
Copyright © 2011 Pearson Addison-Wesley
The Visual Basic Environment
Chapter 1 - Slide 46
Copyright © 2011 Pearson Addison-Wesley
Downloading Visual Basic
Chapter 1 - Slide 47
Steps to download the software!
Posted on Bb and Emailed: Monday, October 17, 2012
1. To download the Visual Basic 2010 Express software go to the
following web site and click on the Download link below. -
http://www.microsoft.com/express/downloads/
2. On the gray bar click on 2010 Express and out of the resulting
menu select Visual Basic 2010 Express.
3. Leave English as the download language and proceed to install the
software by clicking on the link Install now.
Copyright © 2011 Pearson Addison-Wesley
The Visual Basic Tutoring Help
Chapter 1 - Slide 48
Visual Basic Tutoring Lab Open!
Posted on Bb and Emailed: Monday, October 8, 2012
The College Tutoring lab offers tutoring
Tutor: May Ann
Days/Times:
Mondays from 11:00 a.m. to 2:30 p.m.
Thursdays from 2:00 p.m. to 5:30 p.m.
You MUST sign up in the tutoring lab--ahead of time .

Contenu connexe

Tendances

Visual basic
Visual basicVisual basic
Visual basic
Dharmik
 
Introduction to visual basic
Introduction to visual basicIntroduction to visual basic
Introduction to visual basic
Manav Khandelwal
 
Vb.net session 02
Vb.net session 02Vb.net session 02
Vb.net session 02
Niit Care
 
Visual basic ppt for tutorials computer
Visual basic ppt for tutorials computerVisual basic ppt for tutorials computer
Visual basic ppt for tutorials computer
simran153
 
VB.Net GUI Unit_01
VB.Net GUI Unit_01VB.Net GUI Unit_01
VB.Net GUI Unit_01
Prashanth Shivakumar
 
Chapter 01
Chapter 01Chapter 01
Chapter 01
llmeade
 
Vb.net session 01
Vb.net session 01Vb.net session 01
Vb.net session 01
Niit Care
 

Tendances (20)

Visual basic
Visual basicVisual basic
Visual basic
 
Vb.net ide
Vb.net ideVb.net ide
Vb.net ide
 
Ch02 bronson
Ch02 bronsonCh02 bronson
Ch02 bronson
 
Introduction to visual basic
Introduction to visual basicIntroduction to visual basic
Introduction to visual basic
 
Vb.net class notes
Vb.net class notesVb.net class notes
Vb.net class notes
 
Vb.net session 02
Vb.net session 02Vb.net session 02
Vb.net session 02
 
History of Visual Basic Programming
History of Visual Basic ProgrammingHistory of Visual Basic Programming
History of Visual Basic Programming
 
Visual Basic IDE Introduction
Visual Basic IDE IntroductionVisual Basic IDE Introduction
Visual Basic IDE Introduction
 
Visual basic ppt for tutorials computer
Visual basic ppt for tutorials computerVisual basic ppt for tutorials computer
Visual basic ppt for tutorials computer
 
VB.Net GUI Unit_01
VB.Net GUI Unit_01VB.Net GUI Unit_01
VB.Net GUI Unit_01
 
Programming basics
Programming basicsProgramming basics
Programming basics
 
Vbasic
VbasicVbasic
Vbasic
 
Visual Basic 6.0
Visual Basic 6.0Visual Basic 6.0
Visual Basic 6.0
 
Visual Studio IDE
Visual Studio IDEVisual Studio IDE
Visual Studio IDE
 
Chapter 01
Chapter 01Chapter 01
Chapter 01
 
Vb.net session 01
Vb.net session 01Vb.net session 01
Vb.net session 01
 
Visual programming
Visual programmingVisual programming
Visual programming
 
Visusual basic
Visusual basicVisusual basic
Visusual basic
 
Visual Studio
Visual StudioVisual Studio
Visual Studio
 
Introduction to Visual Basic 6.0 Fundamentals
Introduction to Visual Basic 6.0 FundamentalsIntroduction to Visual Basic 6.0 Fundamentals
Introduction to Visual Basic 6.0 Fundamentals
 

Similaire à Chapter 01 Introduction to Visual Basic

Chapter 1 Operating Systems Fundamentals
Chapter 1 Operating Systems FundamentalsChapter 1 Operating Systems Fundamentals
Chapter 1 Operating Systems Fundamentals
RobNieves1
 
CH. 4 Operating Systems and Utility Programs
CH. 4 Operating Systems and Utility ProgramsCH. 4 Operating Systems and Utility Programs
CH. 4 Operating Systems and Utility Programs
malik1972
 
Chapter 05 os dan utility program csc & tts
Chapter 05 os dan utility program csc & ttsChapter 05 os dan utility program csc & tts
Chapter 05 os dan utility program csc & tts
Hisyam Rosly
 
Chapter 01 - introduction for C++
Chapter 01 - introduction for C++Chapter 01 - introduction for C++
Chapter 01 - introduction for C++
wahida_f6
 

Similaire à Chapter 01 Introduction to Visual Basic (20)

Chapter 01
Chapter 01Chapter 01
Chapter 01
 
Chapter 01
Chapter 01Chapter 01
Chapter 01
 
Chapter1.ppt
Chapter1.pptChapter1.ppt
Chapter1.ppt
 
Week 01.pdf
Week 01.pdfWeek 01.pdf
Week 01.pdf
 
programing fundamentals by dr. wheedh khan
programing fundamentals by dr. wheedh khanprograming fundamentals by dr. wheedh khan
programing fundamentals by dr. wheedh khan
 
Introduction to computers and programing.pptx
Introduction to computers and programing.pptxIntroduction to computers and programing.pptx
Introduction to computers and programing.pptx
 
Chapter 1 Operating Systems Fundamentals
Chapter 1 Operating Systems FundamentalsChapter 1 Operating Systems Fundamentals
Chapter 1 Operating Systems Fundamentals
 
Problem Solving and Program Design in C_1.pdf
Problem Solving and Program Design in C_1.pdfProblem Solving and Program Design in C_1.pdf
Problem Solving and Program Design in C_1.pdf
 
Introduction to Computers and Programming
Introduction to Computers and ProgrammingIntroduction to Computers and Programming
Introduction to Computers and Programming
 
Unit 1.pptx
Unit 1.pptxUnit 1.pptx
Unit 1.pptx
 
merged (1).pdf
merged (1).pdfmerged (1).pdf
merged (1).pdf
 
BAIT1003 Chapter 6
BAIT1003 Chapter 6BAIT1003 Chapter 6
BAIT1003 Chapter 6
 
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
 
CH. 4 Operating Systems and Utility Programs
CH. 4 Operating Systems and Utility ProgramsCH. 4 Operating Systems and Utility Programs
CH. 4 Operating Systems and Utility Programs
 
computer networking
computer networking computer networking
computer networking
 
Chapter 1 - Prog101.ppt
Chapter 1 - Prog101.pptChapter 1 - Prog101.ppt
Chapter 1 - Prog101.ppt
 
Chapter 05 os dan utility program csc & tts
Chapter 05 os dan utility program csc & ttsChapter 05 os dan utility program csc & tts
Chapter 05 os dan utility program csc & tts
 
UNIT-111.pptx
UNIT-111.pptxUNIT-111.pptx
UNIT-111.pptx
 
Chapter 01 - introduction for C++
Chapter 01 - introduction for C++Chapter 01 - introduction for C++
Chapter 01 - introduction for C++
 
c programming 1-1.pptx
c programming 1-1.pptxc programming 1-1.pptx
c programming 1-1.pptx
 

Dernier

Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
ssuserdda66b
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 

Dernier (20)

Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 

Chapter 01 Introduction to Visual Basic

  • 1. Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. CISC 181 – Principles of Information Systems San Diego Mesa College Prof. George Bonilla Chapter 1 Introduction to Programming and Visual Basic
  • 2. Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Section 1.1 COMPUTER SYSTEMS: HARDWARE AND SOFTWARE Computer systems consist of similar hardware devices and hardware components. This section provides an overview of computer hardware and software organization.
  • 3. Copyright © 2011 Pearson Addison-Wesley Computer Hardware • Refers to the physical components • Not one device but a system of many devices • Major types of components include: – Central Processing Unit – Main memory – Secondary storage devices – Input devices – Output devices Chapter 1 - Slide 3
  • 4. Copyright © 2011 Pearson Addison-Wesley Organization of a Computer System Chapter 1 - Slide 4
  • 5. Copyright © 2011 Pearson Addison-Wesley The CPU • Fetches instructions from main memory • Carries out the operations commanded by the instructions • Each instruction produces some outcome • CPU gets instructions from a program • A program is an entire sequence of instructions • Instructions are stored as binary numbers • Binary number - a sequence of 1’s and 0’s Chapter 1 - Slide 5
  • 6. Copyright © 2011 Pearson Addison-Wesley Main Memory • Commonly known as random access memory, or just RAM • Holds instructions and data needed for programs that are currently running • RAM is usually a volatile type of memory • Contents are lost when power is turned off • Used as temporary storage Chapter 1 - Slide 6
  • 7. Copyright © 2011 Pearson Addison-Wesley Secondary Storage • A nonvolatile storage medium • Contents retained while power is off • Hard disk drives are most common • Records data magnetically on a circular disk • Provides fast access to large amounts of data • Optical devices store data on CD’s as pits • USB flash memory devices • High capacity device plugs into USB port • Portable, reliable, and fits easily in a pocket Chapter 1 - Slide 7
  • 8. Copyright © 2011 Pearson Addison-Wesley Input Devices • Any type of device that provides data to a computer from the outside world • For example: – Keyboard – Mouse – Scanner Chapter 1 - Slide 8
  • 9. Copyright © 2011 Pearson Addison-Wesley Output Devices • Any type of device that provides data from a computer to the outside world • Examples of output data: • A printed report • An image such as a picture • A sound • Common output devices include: • Monitor (display screen) • Printer Chapter 1 - Slide 9
  • 10. Copyright © 2011 Pearson Addison-Wesley Software • The programs that run on a computer • Two major categories – Operating systems • Controls the processes within the computer • Manages the computer's hardware devices – Application Software • Solve problems or perform tasks needed by users • Examples include word processing, spreadsheets, games, Internet browsers, playing music, etc) • Each program is referred to as an application • This book develops applications in Visual Basic Chapter 1 - Slide 10
  • 11. Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Section 1.2 PROGRAMS AND PROGRAMMING LANGUAGES A program is a set of instructions a computer follows in order to perform a task. A programming language is a special language used to write computer programs.
  • 12. Copyright © 2011 Pearson Addison-Wesley What is a Program? • Computers can only follow instructions • A computer program is a set of instructions on how to solve a problem or perform a task • In order for a computer to compute someone’s gross pay, we must tell it to perform the steps on the following slide Chapter 1 - Slide 12
  • 13. Copyright © 2011 Pearson Addison-Wesley Computing Gross Pay 1. Display message: "How many hours did you work?" 2. Allow user to enter number of hours worked 3. Store the number the user enters in memory 4. Display message: "How much are you paid per hour?" 5. Allow the user to enter an hourly pay rate 6. Store the number the user enters in memory 7. Multiply hours worked by pay rate and store the result in memory 8. Display a message with the result of the previous step This well-defined, ordered set of steps for solving a problem is called an algorithm Chapter 1 - Slide 13
  • 14. Copyright © 2011 Pearson Addison-Wesley States and Transitions Memory snapshots show states of the program 3. Store hours worked in memory 6. Store hourly pay rate in memory 7. Multiply hours worked by pay rate and store amount earned in memory Program Starting State hours worked ?? hourly pay rate ?? amount earned ?? Snapshot after Step 3 hours worked 20 hourly pay rate ?? amount earned ?? Snapshot after Step 6 hours worked 20 hourly pay rate 25 amount earned ?? Snapshot after Step 7 hours worked 20 hourly pay rate 25 amount earned 500 Chapter 1 - Slide 14
  • 15. Copyright © 2011 Pearson Addison-Wesley Programming Languages • The steps in our algorithm must be stated in a form the computer understands • The CPU processes instructions as a series of 1’s and 0’s called machine language • This is a tedious and difficult format for people • Instead, programming languages allow us to use words instead of numbers • Software converts the programming language statements to machine language Chapter 1 - Slide 15
  • 16. Copyright © 2011 Pearson Addison-Wesley Common Programming Languages • Visual Basic • Python • JavaScript • Java • C# • C • C++ • PHP • Visual Basic is not just a programming language • It’s a programming environment with tools to: – Create screen elements – Write programming language statements Chapter 1 - Slide 16
  • 17. Copyright © 2011 Pearson Addison-Wesley What is a Program Made Of? • Keywords (Reserved Words) – Words with special meaning that make up a high-level programming language, cannot be used for any other purpose • Operators – Special symbols that perform various operations on data • Variables – Used to store data in memory, named by the programmer • Syntax – Set of rules – Similar to the syntax (rules) of a spoken language, such as English, but must be strictly followed – If even a single syntax error appears in a program, it will not compile or execute Chapter 1 - Slide 17
  • 18. Copyright © 2011 Pearson Addison-Wesley What is a Program Made Of? • Statements – Instructions made up of keywords, variables, and operators. • Procedures – Set of programming statements that perform a specific task • Comments (Remarks) – Ignored when the program runs, help human reader understand the purpose of programming statements – In Visual Basic, any statement that begins with an apostrophe (') Chapter 1 - Slide 18
  • 19. Copyright © 2011 Pearson Addison-Wesley Methods of Programming • Procedural – Constructed as a set of procedures (operational, functional units) – Each procedure is a set of instructions – The Gross Pay computation is a procedure • Object-Oriented – Uses real-world objects such as students, transcripts, and courses – Objects have data elements called attributes – Objects also perform actions Chapter 1 - Slide 19
  • 20. Copyright © 2011 Pearson Addison-Wesley Example of an Object • This is a Visual Basic GUI object called a form • Contains data and actions • Data, such as Hourly Pay Rate, is a text property that determines the appearance of form objects • Actions, such as Calculate Gross Pay, is a method that determines how the form reacts • A form is an object that contains other objects such as buttons, text boxes, and labels Chapter 1 - Slide 20
  • 21. Copyright © 2011 Pearson Addison-Wesley Example of an Object • Form elements are objects called controls • This form has: – Two TextBox controls – Four Label controls – Two Button controls • The value displayed by a control is held in the text property of the control • Left button text property is Calculate Gross Pay • Buttons have methods attached to click events Chapter 1 - Slide 21
  • 22. Copyright © 2011 Pearson Addison-Wesley Event Driven Programming: Events • The GUI environment is event-driven • An event is an action that takes place within a program – Clicking a button (a Click event) – Keying in a TextBox (a TextChanged event) • Visual Basic controls are capable of detecting many, many events • A program can respond to an event if the programmer writes an event procedure Chapter 1 - Slide 22
  • 23. Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Section 1.3 MORE ABOUT CONTROLS AND PROGRAMMING As a Visual Basic programmer, you must design and create an application’s GUI elements (forms and other controls) and the programming statements that respond to and/or perform actions (event handlers).
  • 24. Copyright © 2011 Pearson Addison-Wesley Visual Basic Controls • As a Windows user you’re already familiar with many Visual Basic controls: – Label - displays text the user cannot change – TextBox - allows the user to enter text – Button – performs an action when clicked – RadioButton - A round button that is selected or deselected with a mouse click – CheckBox – A box that is checked or unchecked with a mouse click – Form - A window that contains these controls • Tutorial 1-3 demonstrates these controls Chapter 1 - Slide 24
  • 25. Copyright © 2011 Pearson Addison-Wesley Tutorial 1-3, Visual Basic Controls Chapter 1 - Slide 25
  • 26. Copyright © 2011 Pearson Addison-Wesley The Name Property • All controls have properties • Each property has a value (or values) • Not all properties deal with appearance • The name property establishes a means for the program to refer to that control • Controls are assigned relatively meaningless names when created • Programmers usually change these names to something more meaningful Chapter 1 - Slide 26
  • 27. Copyright © 2011 Pearson Addison-Wesley Examples of Names • The Label controls use the default names (Label1, etc.) • Text boxes, buttons, and the Gross Pay label play an active role in the program and have been changed btnCalcGrossPay btnClose txtHoursWorked txtPayRate lblGrossPay Label1 Label2 Label3 Form1 Chapter 1 - Slide 27
  • 28. Copyright © 2011 Pearson Addison-Wesley Naming Conventions • Control names must start with a letter • Remaining characters may be letters, digits, or underscore • 1st 3 lowercase letters indicate the type of control – txt… for Text Boxes – lbl… for Labels – btn… for Buttons • After that, capitalize the first letter of each word • txtHoursWorked is clearer than txthoursworked Chapter 1 - Slide 28
  • 29. Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Section 1.4 THE PROGRAMMING PROCESS The programming process consists of several steps, which include designing, creating, testing, and debugging activities.
  • 30. Copyright © 2011 Pearson Addison-Wesley Step 1 of Developing an Application • Clearly define what the program is to do • For example, the Wage Calculator program: – Purpose: To calculate the user’s gross pay – Input: Number of hours worked, hourly pay rate – Process: Multiply number of hours worked by hourly pay rate (result is the user’s gross pay) – Output: Display a message indicating the user’s gross pay Chapter 1 - Slide 30
  • 31. Copyright © 2011 Pearson Addison-Wesley Step 2 of Developing an Application • Visualize the application running on the computer and design its user interface Chapter 1 - Slide 31
  • 32. Copyright © 2011 Pearson Addison-Wesley Step 3 of Developing an Application • Determine the controls needed Type Name Description TextBox txtHoursWorked Allows the user to enter the number of hours worked. TextBox txtPayRate Allows the user to enter the hourly pay rate Label lblGrossPay Displays the gross pay, after the btnCalcGrossPay button has been clicked Button btnCalcGrossPay When clicked, multiplies the number of hours worked by the hourly pay rate Button btnClose When clicked, terminates the application Label (default) Description for Number of Hours Worked TextBox Label (default) Description for Hourly Pay Rate TextBox Label (default) Description for Gross Pay Earned Label Form (default) A form to hold these controls Chapter 1 - Slide 32
  • 33. Copyright © 2011 Pearson Addison-Wesley Step 4 of Developing an Application • Define the values of each control’s relevant properties Control Type Control Name Text Form (Default) "Wage Calculator" Label (Default) "Number of Hours Worked" Label (Default) "Hourly Pay Rate" Label (Default) "Gross Pay Earned" Label lblGrossPay "$0.00" TextBox txtHoursWorked "" TextBox txtPayRate "" Button btnCalcGrossPay "Calculate Gross Pay" Button btnClose "Close" Chapter 1 - Slide 33
  • 34. Copyright © 2011 Pearson Addison-Wesley Step 5 of Developing an Application • Determine the event handlers and other code needed for each control Method Description btnCalcGrossPay_Click Multiplies hours worked by hourly pay rate These values are entered into the txtHoursWorked and txtPayRate TextBoxes Result is stored in lblGrossPay Text property btnClose_Click Terminates the application Chapter 1 - Slide 34
  • 35. Copyright © 2011 Pearson Addison-Wesley Step 6 of Developing an Application • Create a flowchart or pseudocode version of the code – A flowchart is a diagram that graphically depicts the flow of a method – Pseudocode is a cross between human language and a programming language Chapter 1 - Slide 35
  • 36. Copyright © 2011 Pearson Addison-Wesley Step 7 of Developing an Application • Check the code for errors: – Read the flowchart and/or pseudocode – Step through each operation as though you are the computer – Use a piece of paper to jot down the values of variables and properties as they change – Verify that the expected results are achieved Chapter 1 - Slide 36
  • 37. Copyright © 2011 Pearson Addison-Wesley Step 8 of Developing an Application • Use Visual Basic to create the forms and other controls identified in step 3 – This is the first use of Visual Basic, all of the previous steps have just been on paper – In this step you develop the portion of the application the user will see Chapter 1 - Slide 37
  • 38. Copyright © 2011 Pearson Addison-Wesley Step 9 of Developing an Application • Use the flowcharts or pseudocode from step 6 to write the actual code – This is the second step on the computer – In this step you develop the methods behind the click event for each button – Unlike the form developed on step 8, this portion of the application is invisible to the user Chapter 1 - Slide 38
  • 39. Copyright © 2011 Pearson Addison-Wesley Step 10 of Developing an Application • Attempt to run the application - find syntax errors – Correct any syntax errors found – Syntax errors are the incorrect use of an element of the programming language – Repeat this step as many times as needed – All syntax errors must be removed before Visual Basic will create a program that actually runs Chapter 1 - Slide 39
  • 40. Copyright © 2011 Pearson Addison-Wesley Step 11 of Developing an Application • Run the application using test data as input – Run the program with a variety of test data – Check the results to be sure that they are correct – Incorrect results are referred to as a runtime error – Correct any runtime errors found – Repeat this step as many times as necessary Chapter 1 - Slide 40
  • 41. Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Section 1.5 VISUAL STUDIO AND VISUAL BASIC EXPRESS EDITION (THE VISUAL BASIC ENVIRONMENT) Visual Studio and Visual Basic Express Edition consist of tools that you use to build Visual Basic applications. The first step in using Visual Basic is learning about these tools.
  • 42. Copyright © 2011 Pearson Addison-Wesley The Visual Studio IDE • Visual Studio is an integrated development environment, often abbreviated as IDE – Provides everything needed to create, test, and debug software including: • The Visual Basic language • Form design tools to create the user interface • Debugging tools to help find and correct programming errors [ Adm. Grace Hopper-1947; Thomas Edison-1878 ] Chapter 1 - Slide 42
  • 43. Copyright © 2011 Pearson Addison-Wesley The Visual Studio IDE • Visual Studio is an integrated development environment, often abbreviated as IDE – Provides everything needed to create, test, and debug software including: • The Visual Basic language • Form design tools to create the user interface • Debugging tools to help find and correct programming errors [ Adm. Grace Hopper-1947; Thomas Edison-1878 ] • Visual Studio supports other languages beside Visual Basic such as C++ and C# Chapter 1 - Slide 43
  • 44. Copyright © 2011 Pearson Addison-Wesley The Visual Basic Environment • Tutorial 1-4 introduces elements of the IDE: – Customizing the IDE • Design window – a place to design and create a form • Solution Explorer window – shows files in the solution • Properties window – modify properties of an object Chapter 1 - Slide 44
  • 45. Copyright © 2011 Pearson Addison-Wesley The Visual Basic Environment • Tutorial 1-4 introduces elements of the IDE: – Customizing the IDE • Dynamic Help window – a handy reference tool • Toolbar – contains icons for frequently used functions • Toolbox window – objects used in form design • Tooltips – a short description of button’s purpose Chapter 1 - Slide 45
  • 46. Copyright © 2011 Pearson Addison-Wesley The Visual Basic Environment Chapter 1 - Slide 46
  • 47. Copyright © 2011 Pearson Addison-Wesley Downloading Visual Basic Chapter 1 - Slide 47 Steps to download the software! Posted on Bb and Emailed: Monday, October 17, 2012 1. To download the Visual Basic 2010 Express software go to the following web site and click on the Download link below. - http://www.microsoft.com/express/downloads/ 2. On the gray bar click on 2010 Express and out of the resulting menu select Visual Basic 2010 Express. 3. Leave English as the download language and proceed to install the software by clicking on the link Install now.
  • 48. Copyright © 2011 Pearson Addison-Wesley The Visual Basic Tutoring Help Chapter 1 - Slide 48 Visual Basic Tutoring Lab Open! Posted on Bb and Emailed: Monday, October 8, 2012 The College Tutoring lab offers tutoring Tutor: May Ann Days/Times: Mondays from 11:00 a.m. to 2:30 p.m. Thursdays from 2:00 p.m. to 5:30 p.m. You MUST sign up in the tutoring lab--ahead of time .