Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 36

PROGRAMMING

LANGUAGE

The Visual Basic Environment
WHAT IS A PROGRAMMING
LANGUAGE?

If people express themselves using a
language with many words, computer
use a simple language consisting of
only 1’s and 0’s which stands for 1 =
ON, 0 = OFF. (Machine Language)
HOW PROGRAMMING WORKS?


Computer is not that “smart” – it is only
an electronic device that switches and
work just ON/OFF, we need programs so
that it will tell the computer what to do
HOW DOES USERS AND COMPUTERS
UNDERSTAND EACH OTHER?

 By using programming languages, because it
acts as a translator between the user and the
computer.
 Rather than learning the language of the
computer, just use a programming language to
instruct the computer in a way that is easier to
understand.
 As a programmer you don’t have to understand
what computer is doing, all you have to do is
understand how different programming
language works.
Evolution:

To write a program for a computer, we
must use a computer language. A computer
language is a set of predefined words that
are combined into a program according to
predefined rules (syntax). Over the years,
computer languages have evolved from
machine language to high-level languages
3 TYPES OF PROGRAMMING LANGUAGE


 MACHINE LANGUAGE – use codes like 0’s and 1’s
that only the computer can understand.

The only language understood by a computer is machine


language.

 ASSEMBLY LANGUAGE – use symbols and three
letters mnemonics to represent machine instructions.


The next evolution in programming came with the
idea of replacing binary code for instruction and
addresses with symbols or mnemonics. Because they
used symbols, these languages were first known as
symbolic languages. The set of these mnemonic
languages were later referred to as assembly
languages.
Example :


 HIGH-LEVEL LANGUAGE – use of program
statements similar to words and symbols of the
English language. (like the Visual Basic Codes)


Ex.

VISUAL BASIC

VISUAL BASIC – a high-level programming language
that evolved from the earlier DOS version called
BASIC

- it is called high level programming language because


the codes look a bit like English language.
THE VISUAL BASIC PROGRAMMING
LANGUAGE

VISUAL BASIC is a VISUAL and event driven
programming Language.

VISUAL – refers to the method used to create what the


user sees- the graphical user interface (GUI).

BASIC – refers to the Basic Programming language.


(Beginners All-Purpose Symbolic Instruction Code)

 In Visual Basic – programming is done in a text-
based environment and the program is executed
sequentially.

 It is event driven because users may click on a


certain object randomly, so each object has to
programmed independently to be able to response to
those actions (events).

 VB is made up of many subprograms; each with its
own program code which can be executed
independently and at the same time can be linked
together in one way or another.

 If we have verbs and nouns in our own language, VB


also have different types of words known as
programming elements.
VISUAL BASIC LANGUAGE


 PROGRAMMING ELEMENTS – includes
statements, declaration methods, operators and
keywords.

 - VB have SYNTAX and tools such as:


INTELLISENSE – guidance in using the correct syntax
when writing programs
 If our language have structure so is VB Language:


VB Our Language
Structure Book
Modules Chapter
Procedures Paragraph
Line of Codes Sentences

VISUAL BASIC
ENVIRONMENT

VB ENVIRONMENT

 Open VB – you can see a
project which is a collection
of files that make up your
application.

 These are various types


of applications that can be created, but we are going to
concentrate on Standard EXE program (executable
programs).
VB Interface (GUI)


Visual Basic 6 Interactive Development Environment

Project
Toolbox Explorer

Form
Designer
Window

Properties
window

Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 22


Fig. 1.3 Control Toolbox

a) The Text Box -The text box is the standard control that is
used to receive input from the user as well as to display
the output. It can handle string (text) and numeric data but
not images or pictures. Strings in a text box can be
converted to numeric data by using the function Val(text).
b) The Label - is a very useful control for Visual Basic, as
it is not only used to provide instructions and guides to
the users, it can also be used to display outputs. One of its
most important properties is Caption. Using the syntax
label.Caption, it can display text and numeric data. You
can change its caption in the properties window and also
at runtime. Please refer to Example below
 Sample Design: To calculate the volume of a
cylinder.

Fig. 1.3 Control Toolbox

C.)The Command Button - The command button is a very
important control as it is used to execute commands. It displays
an illusion that the button is pressed when the user clicks on it.
The most common event associated with the command button
is the Click event, and the syntax for the procedure is
Private Sub Command1_Click()
‘To add the values in Textbox 1 and text box 2
Sum = Val(num1.Text) + Val(num2.Text)
‘To display the answer on label 1
Label3.Caption = Sum
End Sub
Sample design

Instructions

 Insert Two Labels rename it with Number 1, Number 2
 Then insert TEXTboxes to be used to enter two numbers.
 Create another Label that will be used to display the SUM

 Insert a command button to be programmed to calculate


the sum of the two numbers using the plus operator. The
program creates a variable, ‘sum’, to accept the summation
of values from Textbox 1 and text box 2.
 The procedure to calculate and display the output on the
label is already shown above
Type here the instructions


The Properties of the Controls

 Before writing an event procedure for the
control to response to a user's input, you have
to set certain properties for the control to
determine its appearance and how it will work
with the event procedure.
 You can set the properties of the controls in
the properties window or at runtime.
 You can rename the form caption to any name
that you like best.
Project 2:


The CODE

 The Codes: To calculate the sum of two numbers:


doubleclick on the Calculate button and enter the codes
between Private Sub OK_Click( ) and End Sub

Private Sub OK_Click( )


End Sub
when you run the program , you should be able to see the
interface as shown above. if you enter a value each in the
radius box and the height box, then click OK, the value of
of the Volume will be displayed in the volume box.
 The Codes: To calculate the volume of a cylinder.
doubleclick on the O.K button and enter the codes

between Private Sub OK_Click( ) and End Sub

Private Sub OK_Click( )


r = Val(radius.Text)
h = Val(hght.Text)
pi = 22 / 7
v = pi * (r ^ 2) * h
volume.Text= Str$(v)
End Sub
when you run the program , you should be able to see the
interface as shown above. if you enter a value each in the
radius box and the height box, then click OK, the value of
of the Volume will be displayed in the volume box.
References:


 https://www.northeastern.edu/graduate/blog/mos
t-popular-programming-languages
/
 https://docs.microsoft.com/en-us/dotnet/visual-ba
sic/language-reference/modules#:~:text=Visual%20
Basic%20provides%20several%20modules,directory
%20operations%2C%20and%20so%20on
.
 https://
docs.microsoft.com/en-us/dotnet/api/microsoft.vis
ualbasic.controlchars?view=net-6.0

You might also like