Professional Documents
Culture Documents
ANDHRA PRADESH
Name : K SREE RAMACHARYULU
Designation : LECTURER
Branch : Commercial & Comp. Practice
Institute : Govt. Polytechnic, SRIKAKULAM
Year / Semester : V
Subject : Visual Basic-I
Subject Code : CCP-503
Duration : 50 Minuets
Topic : Programming Fundamentals
Sub. Topic : VB Environment, Basics of VB
Programming Fundamentals.
Teaching Aids : PPT, Animation Clips & Images
CCP503.22 1
Objectives
On completion of this period you would be able to
understand
Definition of the variable
Types of Variables
Manipulation of Variables
CCP503.22 2
Structure
Variable - Definition
Declaring variable - Types
Examples for Variable declaration
Naming conventions of the variables
CCP503.22 3
Recap
CCP503.22 4
Introduction to Variables
In any Programming Language variables are
used to store data values during a programme
execution temporarily.
CCP503.22 5
Variable Definition
Variable is a placeholder used to store data values and recall
them at will
Variables are stored values during a program’s execution.
It has a name and a value.
They have names & Data Types
The Data type of a variable determine how the bits
representing those values are stored in system memory
CCP503.22 6
Example for string data type: -
Name = “Hari”
CCP503.22 7
Example for string data type: -
Ex2. Dim age as integer
Age=20
Here name of the variable is age and the data value
is 20 of the integer data type.
CCP503.22 8
Declaring Variables
In most of the languages, variables must be
declared in advance for the compiler
CCP503.22 9
Declaring Variables
Examples:
1.Dim meter as integer.
2.Dim var1 as variant.
CCP503.22 10
Types of Variable Declaration
Basically two types
2) Explicit Declaration
3) Implicit Declaration
In general we have to use Dim statement which is a keyword
followed by the variable’s name and the data type
Examples:
Dim meters as integer
Dim greetings as string
CCP503.22 11
Key Word
A keyword is also called reserve word which is
used to its intended purpose only.
CCP503.22 12
1. Explicit Declaration
Here all variables must be declared before
they are used
For Example:
4. Dim Marks as Integer
5. Dim name as String
6. Dim total as Integer
7. Dim Age as Integer
CCP503.22 13
Option Explicit variable Declaration
We can find this type by the following
statement:
CCP503.22 14
Different Examples
Dim meter as integer
Dim greetings as string
Meter=100
Greetings=“Welcome to Visual Basic”
CCP503.22 15
2.Implicit Declaration
Here it is not compulsory to specify the data type of
the variable
When VB encounters an undeclared variable on the
spot and uses it automatically.
CCP503.22 16
Examples of Implicit Declaration
Examples:
Dim Name1, var1
Name1 =“Krishna kumar”
Var1 = 123
Here var1 is string type and var2 is integer type
This can be verified by using Type Name()
function,returns variable type
Some more examples
Dim Marks,
Dim Name,
Dim Tot_bal,
Dim Age
CCP503.22 17
Primary Classification of Variables
Basically Variables are classified into 2 types
Numeric
Non Numeric
Under Non-Numeric
String
Date
Boolean
Object
variant
CCP503.22 18
Variable Naming Conventions
CCP503.22 19
Summary
In this Session, you have learnt about …
Definition of Variable,
Types of Variables
CCP503.22 20
Quiz
A. Character
B. Byte
C. String
D. Integer
CCP503.22 21
Quiz
2. Which one of the following case is a NOT a valid
declaration ?
Implicit Declaration
Explicit Declaration
Name as Integer
Dim A
CCP503.22 22
Quiz
CCP503.22 23
Frequently Asked Questions
1. What is variable?
CCP503.22 24