CICS 313:
Visual Basic Programming
Introduction to Visual Basic
Programming
Ghana Technology University College
Lecturer – Dr. Forgor Lempogo
2021
Objectives
By the end of this lesson, you should be able to:
Explain the concept of computer programming
Explain how programmers solve problems
Understand the history and evolution of the VB
programming language
Understand the architecture of the .NET
Framework and Visual Studio Integrated
Development Environment (IDE)
2
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Computer Programming
Programming
The process of giving a computer/ mechanism the
directions it needs to accomplish a task
The act/process of creating computer programs
Programs:
Detailed set of instructions/directions given to computers
to execute in order to generate a desired outcome
Written by programmers using specialized languages
Programmers:
people who write programs
Programmers write computer programs to solve problems
that require a computer solution
3
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Basic Functions of a Program
The basic function of many programs is to:
Accept some form of data (input data)
Manipulate the data in some manner (processing)
Create some form of data that is usable by people
or other computers (output data, or information)
In order for the computer to execute a program:
Program and data must be placed in the
computer’s random access memory (RAM)
4 CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Input Operation
A fundamental operation in most computer programs
involves a user who enters data
5 CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Output Operation (1 of 3)
The second basic program operation is creating
output, or information
6 CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Saving Software and Data
When you develop and write a program, the code you
write and other features, such as the GUI, must be
saved on disk
When you want the program to run, you can have the
program loaded into RAM and executed
The program you write, however, also can save data
Banking applications must save account data
In most cases, data is stored in a database
Collection of data organized in a manner that allows
access, retrieval, and use of that data
7
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Central Processing Unit
The computer’s central processing unit (CPU) can
access the program instructions and the data in RAM to
perform activities as directed by the program
8 CICS 313: Visual Basic Programming - GTUC 2021 Delivery
How Programmers Solve Problems
You cannot solve a problem unless you understand it
You cannot understand a problem unless you
analyze it
Most important components of any problem are the
problem’s output and its input
9 CICS 313: Visual Basic Programming - GTUC 2021 Delivery
How Programmers Solve Problems
1. Analyze the problem
2. Plan the solution/algorithm
3. Desk-check the algorithm
4. Create the user interface
5. Implement the algorithm
6. Desk-check the program
7. Rigorously test the program using the computer
10
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Step 1 – Analyze the Problem
Identify Output
What does the user want to see printed on paper,
displayed on the screen, or stored in a file?
Identify Input
What information will the computer need to know
to print, display, or store the output items?
Analysis step is most difficult problem-solving step
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
11
Step 1 – Analyze Problem ONE
As a Marketing Executive of Zenith Bank,
Kwadjo receives an annual commission
which is calculated by multiplying his annual
sales by a commission rate.
He needs a program that will calculate and
display his annual commission.
12
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Step 1 – Analyze Problem ONE
Input?
Annual Sales
Commission Rate
Output?
Annual Commission
Process?
Multiply Annual sales by commission rate (result
is the user’s annual commission)
13
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Step 2 – Plan the Algorithm
Pseudo code
False code, not standardized
Cannot be understood by a computer
Used by programmers when planning an
algorithm
Flowchart
Uses standardized symbols to visually depict an
algorithm
14
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Step 2 – Plan Algorithm One
Input?
Annual Sales
Commission Rate
Output?
Annual Commission
Algorithm
1. enter the annual sales and commission rate
2. calculate the annual commission by multiplying the
annual sales by the commission rate
3. display the annual commission
15
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Step 2 – Plan the Algorithm (2)
Flowchart symbols
Oval: start/stop symbol
Parallelogram: input/output symbol
Rectangle: process symbol
Flowlines
Connect symbols
Processing item:
intermediate value that algorithm uses when processing
input into output
16
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Algorithm 1 – Flow Chart
Input?
Current Pay
Percentage of Raise
Output?
New Pay
Process?
Multiply current pay by
percentage of raise(result is the
user’s new pay)
17
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Step 1 – Analyze Problem TWO
Mr. Jimah is Paid at the end of every week.
He is expecting to receive a pay raise next
week. However, he is not sure of the actual
percentage.
He needs a program that will calculate and
display his new pay when the percentage of
raise is known.
18
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Step 1 – Analyze Problem Two
Input?
Current Pay
Percentage of Raise
Output?
New Pay
Process?
Multiply current pay by percentage of raise and
add the value to the current pay(result is the
19
user’s new pay)
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Step 2 – Plan Algorithm Two
Input?
Current Pay
Percentage of Raise
Output?
New Pay
Algorithm
1. Enter the current pay and percentage of raise.
2. Calculate the raise by multiplying current pay by
percentage of raise.
3. Calculate new weekly pay by adding the value of the
raise to the current pay.
4. Display the new weekly pay.
20
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Plan Algorithm Two – Flow Chart
Input?
Current Pay
Percentage of Raise
Output?
New Pay
Process?
Multiply current pay by
percentage of raise
add the value to the current pay
result is the user’s new pay
21
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Step 1 – Analyze Problem Three
Students in the BIT Level 300 class optained
various grades in a Mid sem exam. A
computer program is needed to find the
highest and lowest class score.
Create an algorithm for the computer
program needed to solve the above problem.
22
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Step 3 – Desk-Check the Algorithm
Desk-checking (hand-tracing)
Programmer reviews algorithm while seated at
his/her desk
Valid data
Data that algorithm is expecting user to enter
Invalid data
Data that algorithm is not expecting user to enter
25
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Step 3 – Desk-Check the Algorithm
To check correctness, select
certain values and put them
through the algorithm
Do the computation yourself
Use a calculator or spreadsheet
program if necessary
26
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
What Is Visual Basic? (1/2)
Visual Basic is modern, high-level, multi-paradigm,
general-purpose programming language for building
applications using Visual Studio and the .NET
Framework.
Visual Basic is Designed to:
Be easy-to-learn by beginners
Be powerful for experts
use an English-like syntax which promotes clarity and
readability
combines an extensive set of advanced features and a
philosophy that emphasizes flexibility, productivity, and
great tooling.
27
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
What Is Visual Basic? (2/2)
VISUAL
Visual Basic belonges to a class of Visual languages:
Permit the programmer to manipulate graphical objects
directly, with the language providing the necessary code
Permit users to access and format information without
the need for writing any procedural code
BASIC
Visual Basic is from Basic:
BASIC - Beginners All-purpose Symbolic Instruction
Code
a programming language used more than 20 years ago
as part of MS-DOS.
28 CICS 313: Visual Basic Programming - GTUC 2021 Delivery
The Versions of Visual Basic
Visual Basic 1.0 first appeared in 1991.
It was followed by version 2.0 in 1992,
version 3.0 in 1993, version 4.0 in 1995,
version 5.0 in 1997, version 6.0 in 1998.
VB.NET, initially released in February 2002,
was not backward compatible with the
earlier versions of Visual Basic.
29
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Event-Driven Computer Programs
Most Visual Basic programs are event-driven
programs that communicate with the user
through a graphical user interface (GUI)
The GUI usually consists of a window, containing a
variety of objects
An event means the user has initiated an action
that causes the program to perform a type of
processing in response to that action
30 CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Event-Driven Computer Programs
with a Graphical User Interface
For example:
A user might enter data into the program and then click a
button
31 CICS 313: Visual Basic Programming - GTUC 2021 Delivery
What Is Visual Basic . NET?
.NET is a program that sits on top of the Operating
System. Thus, it sits between your software and the
OS.
Provides language interoperability across platforms
Strong emphasis on Web connectivity, using XML web
services to connect and share data between smart
client devices, servers, and developers/users
Platform/language independent
32 CICS 313: Visual Basic Programming - GTUC 2021 Delivery
.NET Framework 4.6.2
.NET technologies and products were designed to work
together to allow businesses to connect information,
people, systems, and devices through software
The .NET Framework provides tools and processes that
developers can use to produce and run programs
Most recent version is .NET Framework 4.6.2
33 CICS 313: Visual Basic Programming - GTUC 2021 Delivery
What Is Visual Basic . NET?
Visual Basic has gone through a few revisions since
VB 6.
VB 2002 (a.k.a. VB 7), VB 2003 (VB 7.1), and VB
2005 (VB 8) etc. are all just revisions of the
language as it uses the .NET Framework.
From 2008, new and improved versions produced at
least, every 2 years(in most cases 1 each year)
Current version – 2019
Visual Basic Versions history
36
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
.NET Class Library (1 of 2)
A class is a named group of program code
A button is an example of a class
A class library stores the class and makes the
class available to all developers who need to use it
Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part.
.NET Class Library (2 of 2)
A button created from a class is called an object, or
sometimes an instance of a class
The process of creating a Button object from the Button
class is called instantiation
Rapid application development (RAD) refers to the
process of using prebuilt classes to make application
development faster, easier, and more reliable
CICS 313: Visual Basic Programming - GTUC 2021
38 Delivery
ADO.NET
ADO.NET (ActiveX Data Objects) provides the
functionality for a program to perform four primary tasks
when working with a database:
Getting the data
Examining the data
Editing the data
Updating the data
CICS 313: Visual Basic Programming - GTUC 2021
39 Delivery
ASP.NET
Allows developers to use Visual Studio to build powerful
and sophisticated web applications
Using ASP.NET classes, programmers can create
websites that perform any function available on web
ASP.NET is designed for cloud technologies and server-
side applications
Cloud computing is the connection of remote servers
hosted on the Internet to store and process data, instead
of storing the information locally on a personal computer
or device
40
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Microsoft Intermediate Language and
Common Language Runtime (1 of 2)
Program compilation translates programming
statements into instructions that can be understood by
the electronics of the computer
Program compilation for a Visual Basic .NET program
creates a set of electronic code expressed in an
intermediate language called the Microsoft
Intermediate Language (MSIL)
When the program is executed, a portion of .NET called
the Common Language Runtime (CLR) reads the
MSIL and causes the instructions within the program to
be executed
41
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Microsoft Intermediate Language and
Common Language Runtime (2 of 2)
42
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Visual Studio IDE (1/2)
Visual Studio is Microsoft’s integrated development
environment (IDE) for creating, running and debugging
applications.
The IDE allows you to create applications by dragging
and dropping existing building blocks into place.
This technique is called visual programming.
It is a Rapid Application Development (RAD) tool
because it is focused on productivity.
43 CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Types of Visual Basic 2019 Applications
Windows Classic Desktop application
Program will run on a computer or other device that
supports the Windows GUI
Windows Universal apps
Designed to run on Windows 8 or Windows 10 computers
and mobile devices
Web application
Uses ASP.NET and runs on a web server
Database application
Written using ADO.NET to reference, access, display, and
update data stored in a database
44
CICS 313: Visual Basic Programming - GTUC 2021 Delivery
Any Questions?
48
CICS 313: Visual Basic Programming - GTUC 2021 Delivery