Reading Material
Computer
I. Introduction
You often have to store values when you perform calculations with Visual Basic.
For example, you might want to calculate several values, compare them, and
perform different operations on them, depending on the result of the comparison.
You have to retain the values if you want to compare them. Visual Basic, just like
most programming languages, uses variables for storing values.
II. Objectives
At the end of the lesson, you should be able to;
1. define variables in Visual Basic 2010;
2. differentiate integer and string variables; and
3. cite example of the utilized variables in Visual Basic 2010.
III. Pretest
Answer the following questions;
1. What is a variable?
2. What is the difference between integer and string variable?
3. How do we utilized variables in Visual Basic 2020?
Saint John Bosco College of Northern Luzon, Inc. Page 1
IV. Discussion / Course Content
LESSON 19: WORKING WITH VARIABLES
With Visual Basic and most programming languages, a variable is a storage area
of the computer’s memory which programs can manipulate.
Each variable in the Visual Basic has specific type. Each type determines the size
and layout of the variable’s memory; the range of variables to be stored within the
memory and the set of operations that can be applied in the variable.
Dim number1 As integer
Dim number2 As Integer
Number1= 3
Number2= 5
Dim - short for dimension. This type of variable is a declaration or you are telling VB
that you are setting up a variable.
Number1 - sample name of variable.
As Integer - this tells VB that variable is going to be a number or an integer.
Example:
Saint John Bosco College of Northern Luzon, Inc. Page 2
Understanding String Variables
Aside from integer variables or numbers, variables can be names or texts. These
are called string variables. To set up a variable to hold a text, there’s a need to use As
String and not As integer.
Dim FirstName As String
Dim LastName As String
FirstName = “Maria”
LastName = “Prado”
VB needs the two double quotation marks before it can identify the text or string.
Example:
Dim FirstName As String
Dim LastName As String
Dim Name As String
FirstName = txtFirst.Text
LastName = txtLast.Text
Name = FirstName & " " & LastName
MessageBox.Show(Name)
Saint John Bosco College of Northern Luzon, Inc. Page 3
V. References:
Introduction to Visual Basic 2010 :
https://www.youtube.com/watch?v=KNwG8YwYR9U
Visual Basic 2010 for Beginners:
https://www.youtube.com/watch?v=7lpuICNVP4U
VI. Post-Test
Via Google Classroom
Saint John Bosco College of Northern Luzon, Inc. Page 4