You are on page 1of 93

VISUAL BASIC

PROGRAMMING ESSENTIALS
UNIT 2: PROGRAMMING
FUNDAMENTALS
Unit Objectives
• Review the basic concepts of programming
• Create program design using flowchart and
pseudocode
• Explore the Integrated Development
Environment of Visual Studio .Net
• Create a simple Visual Basic .Net Project
Lesson Topic

Lesson 3: PROGRAMMING FUNDAMENTALS

Lesson 4: PSEUSODECODE AND FLOWCHART

Lesson 5:INTRODUCTION TO VISUAL STUDIO.NET AND VB.NET


LESSON 3: PROGRAMMING
FUNDAMENTALS
Unit Topics
• The Concept of Computer Programming
• The Programming Languages
• Programming Problem Solving Tips and
Tricks
The Concept of Computer Programming

•The purpose of computer programming is to create sets of


instructions to enable a computer to do a certain process.
• It is the process of designing, writing, testing, debugging,
and maintaining the source c ode of computer programs
•A programming language is a set of words, symbols and
codes that enable human to communicate with computers.
The Concept of Computer Programming

•The process of creating program code often


requires expertise in program algorithm,
design, and logic.
•An algorithm is a sequence of
unambiguous, finite and ordered instructions
to be followed to solve a problem
The Programming Languages
Low Level Programming Languages
The low-level languages are
programming languages that are close to
the operation of a computer. The lowest
level of language par excellence is the
machine code.
The Programming Languages
Low-level programming languages are
sometimes divided into two categories:
1. First generation or machine language is
a language system that executed directly
by a computer processing unit.
The Programming Languages
Example:
A function in 32-bit x 86 machine code to
calculate the nth Fibonacci number.
The Programming Languages
2. Second generation or sometimes called
Assembly Language. This refers to a class
of low-level languages that are used to
write computer programs or to a particular
language.
The Programming Languages
Example:
The same Fibonacci number calculator as
above, but in x 86 assembly language using
Microsoft Macro Assembler (MASM)
syntax.
The Programming Languages
The Programming Languages
High Level Programming Languages
• High-level feature to express algorithms in
a way human does, rather than executing
like the machines.
• The main advantage of high-level
languages over low-level languages is that
they are easier to read, write, and maintain.
The Programming Languages
Third generation languages are the first to
use true English language which is much
easier to use compare to other low level
language.
Often abbreviated 4GL, fourth-generation
languages are programming languages closer
to human languages than typical high-level
programming languages.
The Programming Languages
Here are the examples of high-level
programming languages:
COBOL (Common Business Oriented
Language)
This was developed in the late 1950s and
early 1960s. COBOL is a wordy computer
language. Programs written in COBOL tend
to be much longer than other languages.
The Programming Languages
The Programming Languages
JAVA
This is a high-level
programming language
developed by Sun
Microsystems. Java was
originally called OAK,
and was designed for
handheld devices and
set-top boxes.
The Programming Languages
C++
This is a high-level
programming language
developed by Bjarne
Stroustrup at Bell Labs.
C++ adds object-
oriented features to its
predecessor, C.
The Programming Languages
BASIC (Beginners All –
Purpose Symbolic
Instruction Code)
This program was
developed by John
George Kemeny and
Thomas Kurtz in the
mid1960s at Dartmouth
College.
The Programming Languages
 ADA
A high-level
programming language
developed in the late
1970s and early 1980s
for the United States
Defense Department.
Programming Problem Solving Tips
and Tricks

Here are the basic steps in solving a problem:


1. Study the Problem - This first step is
critical. 
2. Analyze the Problem - In this stage of
problem solving, questions should be
asked and information gathered should be
shifted. 
Programming Problem Solving Tips
and Tricks

3. Identifying Possible Solutions - Identifying


possible solutions to the problem is sometimes
referred to as finding "Optional Solutions"
because the goal is to complete a list of all
conceivable alternatives to the problem. 
4. Selecting the Best Solution - The starting point
in any conscious attempt at rational decision-
making must be the recognition that a problem
exists. 
Programming Problem Solving Tips
and Tricks

5. Evaluating Solutions - There are several


ways to evaluate the chosen solutions, and
writing them all down will help the group to
choose the best solution to the problem.
• Develop and assign weights to criteria
• Prioritize the criteria
• Rate proposed solutions using criteria
• Include other considerations
Programming Problem Solving Tips
and Tricks
6.Develop an Action Plan -
An action plan is a chart
that lists the tasks that
needs to be done and
identifies who will be
responsible for each, when
and what action is
necessary, where to start
and how to start.
Programming Problem Solving Tips
and Tricks

7. Implement the Solution – Sometimes, the


group who choose the solution are not the
ones who will implement it.  If this is the
case, members who select the solution
should clearly explain why they selected it
to the ones who will implement it. 
TEST YOURSELF

Answer Activities on page:

259-260
SKILLS PRACTICE

Do Hands-On Activity on page:

261
END OF LESSON
DISCUSSION
LESSON 4: PSEUSODECODE AND
FLOWCHART
Lesson Topic

• What is Algorithm?

• What is Pseudocode?

• What is Flowchart?
What is Algorithm?
• An algorithm is a sequence of methods that
is performed by a computer to solve a
specific problem.
• It is formally a type of effective method in
which a list of well-defined instructions for
completing a task will, when given an initial
state, proceed through a well-defined series
of successive states, eventually terminating
in an end-state.
What is Algorithm?
Some properties of the algorithm are:
• Finiteness
• Absence of Ambiguity
• Sequence of Execution
• Input and Output
• Effectiveness
• Scope of Definition
What is Pseudocode?
• A PSEUDOCODE specifies the steps of
algorithm using language of control structure.
• It is a compact and informal high-level
description of a computer programming
algorithm that uses the structural conventions
of some programming language, but is
intended for human-reading rather than
machine-reading.
What is Pseudocode?
Example:
What is Pseudocode?
Here is another example of a pseudocode that
initializes two variables.
What is Flowchart?
• A FLOWCHART is a graphical
representation of the algorithm of the
program. It was introduced by Frank Gilberth
in 1921, and they were called “Process Flow
Chart”.
• A FLOWCHART should be used to see how a
whole process works. Flowchart identifies also
the critical points, bottlenecks, or problem
areas in the process.
What is Flowchart?
Types of Flowcharts
Flowcharts can be categorized into four main
types.
1. Document flowchart- showing controls
over a document-flow through a system,
such as payroll information, internal
memos, and office mail.
What is Flowchart?
2. System flowchart- showing controls on how
the entire system works by demonstrating
how data flows and what decisions are made
to control.
3. Data flowchart-showing controls over a
data-flow in a system.
4. Program flowchart-showing controls over
how program works within a system.
What is Flowchart?
The Flowchart Symbols
What is Flowchart?
What is Flowchart?
What is Flowchart?
What is Flowchart?
Flowcharting Guidelines
1. Flowcharts should be read from top to
bottom and left to right—the same way
you read a page in a book.
2. Avoid intersecting flow lines.
3. Use meaningful description in the symbol.
What is Flowchart?
4. Flowcharts should have plenty of “white
space.”
5. Flowcharts should have a title. A bunch of
symbols on a page can be confusing to read
and evaluate if you don’t know what
they’re trying to present.
6. Flowcharts can be designed using a variety
of tools, both high-tech and low-tech.
What is Flowchart?
Here is the flowchart equivalent of the previous
example for:
What is Flowchart?
Start

Enter Display
Student “Failed”
Grade

No
A
Is grade >= 60

Yes

Display
“Passed” Stop
What is Flowchart?
Start
Example 2
The flowchart Read m , n
given illustrates a
program that Yes m= m + n
accepts an integer
(m, n) and adds
them. If the sum Is m>10

(m) exceeds 10 the No


program stops. Stop
What is Flowchart?
Start
Example 3
The next Sum=0
flowchart Count=

illustrates a
Read
program that a,b,c Yes
accepts integers
a, b, c five times Sum=a+b+c
Count=count+1
and displays its
total sum. Is
count<=5 Display
No Stop
sum
What is Flowchart?
Example 4. Start

This flowchart illustrates the Input hour


calculation of salary pay
based on the input hours and Input rate

rate. After the computation, it


displays the output pay. Pay= hour*rate

The pseudocode of the


program is placed at the left Print pay
side.
  Stop
What is Flowchart?
Flowchart for Function or Subroutine Module

A subroutine is a process that can be


repeated several times in the program. It is
mostly used in iteration
What is Flowchart?
Begin
Begin
Print “input 3 print”input 3 number”
number “ input a,b,c
Input a,b,c avg = average (a,b,c)
print “Average is “, avg
End
Average

Print “average
is”, avg

End
What is Flowchart?
Now, let see what the process behind the
Average module is the following:
Average
Begin Average (a,b,c)
sum = a+b+c
avg = sum /3.0
sum = a + b + c return avg
avg = sum /3 End

Exit
TEST YOURSELF

Answer Activities on page:

262-263
SKILLS PRACTICE

Do Hands-On Activity on page:

264-265
END OF LESSON
DISCUSSION
LESSON 5 : INTRODUCTION TO
VISUAL STUDIO.NET AND VB.NET
Lesson Topic
• Visual Studio Solution: From 6.0 to .Net
Version
• Basic .Net Fundamentals
• Understanding VB.Net Programming
Concepts
• Exploring the Integrated Development
Environment
• Creating a Simple Visual Basic.Net Project
Visual Studio Solution: From 6.0 to .Net Version

• There are quite a few differences in VB6


and VB.NET. VB6 is simple to use
because it contains many powerful
functions and features in a runtime library
that must be shipped with the programs
you compile in VB6.
• VB6 is an interpreter-based language. VB6
is not a type-safe language.
Visual Studio Solution: From 6.0 to .Net Version

• VB6 used ‘On Error ‘Goto’ syntax to handle


exceptions at runtime.
• A lot of code in VB6 was hidden from
developer.
• VB6 does not allow developing the
multithreaded applications.
• VB6 is only considered good for desktop
windows application.
Visual Studio Solution: From 6.0 to .Net Version

• Visual Basic 2010 is the latest version of


Visual Basic launched by Microsoft in
2010. VB2010 is almost similar to Visual
Basic 2008, but it has added many new
features.
Visual Studio Solution: From 6.0 to .Net Version

Features and Offerings of Visual Studio.Net


Visual Studio.Net has a lot of cool features.
It supports the language that targets the
common language runtime like C# and
Visual Basic .Net.
Visual Studio Solution: From 6.0 to .Net Version

Some of it is:
1. Process Dialog
In order to debug your DLL projects (a
Microsoft.Net component), you need to
launch an EXE that loads your
component
Visual Studio Solution: From 6.0 to .Net Version

2. SQL Server stored Procedure Debugging


To use this feature make sure that the
SQL debugging components is installed
on your computer and you have enough
privileges to debug stored procedures.
Visual Studio Solution: From 6.0 to .Net Version

3. Project References
To add an assembly reference to your
project, right click on the referencing
project in the Solution Explorer and choose
Add Reference.
4. Class View
The class view allows you to see the
metadata for the types in your project.
Visual Studio Solution: From 6.0 to .Net Version

5. Command Window
The command window has the ability to set
and get values from a stopped program just
like the immediate windows you used on
earlier IDE.
6. Designer-Friendly Custom Controls
You can create your own custom controls
with the designer attributes.
Visual Studio Solution: From 6.0 to .Net Version

7. Macros
A macro is a series of commands and
instructions that you group together as a
single command to accomplish a task.
8. Custom Add-ins
This allows programmers to add unlimited
numbers of features and functionalities
written in Visual Basic, C, C++, C#, or
any .Net Compliant language.
Visual Studio Solution: From 6.0 to .Net Version

9. Custom Tools
A Single-File Generator or a Custom Tool is
a COM extension for Visual Studio that
takes a project file as input, and produce
code.
10. Custom Wizards
These wizards are not called from a dialog
box. Instead, they are called directly from
add-ins, macros, or other types of code.
Basic .Net Fundamentals
The .NET Framework
The Microsoft Visual Basic programming
environment became very popular for its
ease of use and it was a candidate for
serious productive applications
Understanding VB.Net Programming Concepts

• In VB.NET, you can also use reflections to


read the meta-data of types and using
reflection emit you can also generate code to
define and invoke types at runtime.
• VB.NET uses .NET framework class library
along with specialized VB library
(System.VisualBasic) as a standard library.
Understanding VB.Net Programming Concepts

• In VB.NET no code is hidden from


developer and you can access and control
each part of your application.
• In VB.NET you can also develop web
applications, distributed applications,
create .NET windows and web controls and
components, write windows and web
services.
Understanding VB.Net Programming Concepts

• VB.NET is platform independent because


of .Net framework. Programs written in
VB.NET can run on any platform where .Net
framework is present.
• VB.NET also supports language
interoperability with various .NET compliant
languages. This means that you can use and
enhance the code written in other .NET
compliant languages.
Understanding VB.Net Programming Concepts

• VB.NET uses assemblies as its component


architecture.
• VB.NET does not require any registry entry
making the deployment easier
• VB.NET uses ASP.NET to build web
applications.
• VB.NET uses ADO.NET and datasets to
build data access applications.
Understanding VB.Net Programming Concepts

• Visual Basic.NET includes an upgrade tool


to assist in converting VB6 projects to .NET.
The tool adds an upgrade report to your
project listing any problems and inserts
comments into your code and To Do items
into the new Task List indicating where
additional changes need to be made.
Understanding VB.Net Programming Concepts

• Visual Basic 2010 is also a full- pledged


Object-Oriented Programming (OOP)
Language, so it has caught up with other
OOP languages such as C++, Java, C# and
others.
• VB.NET you can create multithreaded
applications.
Understanding VB.Net Programming Concepts

• VB.NET uses the Try…Catch…Finally


syntax to handle exceptions at runtime.
• VB.NET is a compiled language.
• VB.NET uses the .Net Common Language
Runtime (.Net CLR). The CLR is much better
designed and implemented than VB-Runtime.
The CLR uses better code translation through
Just in Time compiler while VB-Runtime
interprets the code.
Exploring the Integrated Development
Environment

This is the Integrated Development


Environment of VB2010 Express.
Exploring the Integrated Development
Environment
3 4

2 5
Exploring the Integrated Development
Environment

1. The New Project/Open Project section –


shows the shortcut for creating or opening new
project.
2. The Recent Projects section - shows a list of
projects that have been created by you
recently.
3. The Getting Started Pane- It provides some
helpful tips to quickly develop your
applications.
Exploring the Integrated Development
Environment

4. The Latest News section- It provides latest


online news about Visual Basic 2010
Express. It will announce new releases and
updates.
5. The Properties section – provides the
name and location of the open project.
Exploring the Integrated Development
Environment

System
Tool bar Menu Bar
Tool
Title Bar

Solution
Explore
r

Toolbox Form
Properties
Server Explorer
Exploring the Integrated Development
Environment

There are four main types of menus you will


encounter:
1. A menu that is disabled is not accessible at
the moment.
2. A menu with three dots means that an
intermediary action is required in order to
apply its assigned behavior.
Exploring the Integrated Development
Environment

3. A menu with an arrow holds a list of menu


items under it.
4. If the shortcut is made of one key only, you
can just press it. If the shortcut is made of
two keys, press and hold the first one, while
you are holding the first, press the second
key once and release the first key.
Creating a Simple Visual Basic.Net Project

1. To start creating your first application, you


need to click on New Project.
Creating a Simple Visual Basic.Net Project

2. The dialog box offers you five types of


projects that you can create.
3. After you have renamed the project, click
OK to continue.
Creating a Simple Visual Basic.Net Project

4. Now drag the button control into the form,


and change its default Text Button1 to OK
in the properties window, the word OK will
appear on the button in the form, as shown:
Creating a Simple Visual Basic.Net Project

5. Now click on the OK button and the code


window appears. Enter the code as follows:
Creating a Simple Visual Basic.Net Project

6. When you run the program and click on the


OK button, a dialog box will appear and
display the "WELCOME TO VISUAL
BASIC 2010" message, as shown below:
Creating a Simple Visual Basic.Net Project

7. Now you have created your first VB2010


program.
TEST YOURSELF

Answer Activities on page:

266-267
SKILLS PRACTICE

Do Hands-On Activity on page:

268
END OF LESSON
DISCUSSION

You might also like