SlideShare a Scribd company logo
Introduction
to
VP Programming
Dr. K. ADISESHA
Introduction
to
Part-2
Introduction
Data types
Queries
Variables
Operators
2
Visual Basic 6
Dr. K. ADISESHA
Conversion
INTRODUCTION
Dr. K. ADISESHA
3
Programming using Visual Basic:
Visual Basic uses building blocks such as Variables, Data Types, Procedures, Functions
and Control Structures in its programming environment.
This section concentrates on the programming fundamentals of Visual Basic with the
blocks specified.
➢ MODULES : Code in Visual Basic is stored in the form of modules, which are of three
type Form Modules, Standard Modules and Class Modules.
➢ Each module can contain:
❖ Declarations :May include constant, type, variable and DLL procedure declarations
❖ Procedures : A sub function, or property procedure that contain pieces of code that
can be executed as a unit.
DATA TYPES
Dr. K. ADISESHA
4
Data types in Visual Basic:
The compiler sets apart a number of bytes for each of the variable depending on the
data type of holds
Data types in Visual Basic
❖ Numeric
❖ String
❖ Date
❖ Boolean
❖ Variant
Data type Size Range
Byte 1 byte Byte Store integer values in the range of 0 - 255
Integer 2 bytes Integer Store integer values in the range of (-32,768) - (+ 32,767)
Long 4 bytes Long Store integer values in the range of (- 2,147,483,468) - (+ 2,147,483,468)
Single 4 bytes Single Store floating point value in the range of (-3.4x10-38) - (+ 3.4x1038)
Double 8 bytes Double Store large floating value which exceeding the single data type value
Currency 8 bytes Currency store monetary values. It supports 4 digits to the right of decimal point
and 15 digits to the left
Decimal 14 bytes Decimal stores value with 28 places to the right of the decimal; smallest non-zero
number is +/-0.0000000000000000000000000001
DATA TYPES
Dr. K. ADISESHA
5
➢ Numeric Data type: The fundamental data types in Visual Basic including variant
are integer, long, single, double, string, currency, byte and boolean.
DATA TYPES
Dr. K. ADISESHA
6
Data types :
➢ String: Use to store alphanumeric values. A variable length string can store
approximately 4 billion characters. Uses storage size10 bytes +
➢ Date : Use to store date and time values. A variable declared as date type can store
both date and time values and it can store date values 01/01/0100 up to 12/31/9999. It
uses storage size of 8 bytes
➢ Boolean : Boolean data types hold either a true or false value. These are not stored as
numeric values and cannot be used as such. Values are internally stored as -1 (True)
and 0 (False) and any non-zero value is considered as true. Uses storage size of2 bytes
➢ Variant : In Visual Basic if we declare a variable without any data type by default the
data type is assigned as variant data type.
VARIABLES
Dr. K. ADISESHA
7
Variables:
Variables are the memory locations which are used to store values temporarily. A
defined naming strategy has to be followed while naming a variable.
➢ A variable name must begin with an alphabet letter and should not exceed 255
characters.
➢ It must be unique within the same scope.
➢ The different ways of declaring variables in Visual Basic are listed below:
❖ Explicit Declaration
❖ Implicit Declaration
❖ Using Option Explicit statement
VARIABLES
Dr. K. ADISESHA
8
Variables:
Variables are the memory locations which are used to store values temporarily. A
defined naming strategy has to be followed while naming a variable.
➢ The following are the rules when naming the variables in Visual Basic:
❖ It must be less than 255 characters
❖ No spacing is allowed
❖ It must not begin with a number
❖ Period is not permitted
❖ Cannot use exclamation mark (!), or the characters @, &, $, #
❖ Cannot repeat names within the same level of scope.
VARIABLES
Dr. K. ADISESHA
9
Explicit variables declaration :
Declaring a variable tells Visual Basic to reserve space in memory. to have more
control over the variables, it is advisable to declare them explicitly.
➢ The variable can have different names and different types of values.
➢ The dim is keyword in visual Basic and has language specific meaning.
➢ Syntax for Declaring Variable
Dim VaribaleName As DataType
➢ Example :
Dim Regno as integer
Dim Myname as string
VARIABLES
Dr. K. ADISESHA
10
Implicit variables declaration :
Visual Basic encounters a new variable, it assigns the default variable type and value.
This is called implicit declaration. Though this type of declaration is easier for the user.
➢ It may be convenient to declare variables implicitly, but it can lead to errors that may
not be recognized at run time
➢ Syntax for Declaring Variable
Dim str1,str2
Str1= “Implicit Declaration”
Str2= Intcount + 1
VARIABLES
Dr. K. ADISESHA
11
Option Explicit variables declaration :
This forces the user to declare all the variables. The Option Explicit statement checks
in the module for usage of any undeclared variables and reports an error to the user.
➢ The user can thus rectify the error on seeing this error message.
➢ The Option Explicit statement can be explicitly placed in the general declaration
section of each module using the following steps.
❖ Click Options item in the Tools menu
❖ Click the Editor tab in the Options dialog box
❖ Check Require Variable Declaration option and
then click the OK button
VARIABLES
Dr. K. ADISESHA
12
Example: Program to find sum and average of two numbers
VARIABLES
Dr. K. ADISESHA
13
Scope of the variable:
The scope of variable determines where you can access that variable in your code.
➢ If a variable is in scope you can read or set its value.
➢ If it is out of scope you will not be able to access it.
➢ Types of scope for variables in visual basic
❖ Global scope: Global variables are in scope anywhere in your application
❖ Module scope :Module level variables are in scope anywhere within the module
where they are declared
❖ Local scope : Local variables are only in scope within the procedure where they
are declared.
Variables
Dr. K. ADISESHA
14
Scope of the variable:
Types of scope for variables in visual basic
➢ Local Variables: A local variable is one that is declared inside a procedure. This
variable is only available to the code inside the procedure.
Dim sum As Integer
➢ Static Variables: Static variables are not reinitialized each time Visual basic invokes a
procedure and therefore retains or preserves value even when a procedure ends.
Static intPermanent As Integer
➢ Module Level Variables: A module level variable is available to all the procedures in
the module. They are declared using the Public or the Private keyword. these
variables are useful for sharing data among procedures in the same module.
Public CustomerName As String
VARIABLES
Dr. K. ADISESHA
15
Local Variables:
A local variable is one that is declared inside a procedure. This variable is only
available to the code inside the procedure and can be declared using the Dim
statements.
Dim sum As Integer
➢ The local variables exist as long as the procedure in which they are declared, is
executing.
➢ Once a procedure is executed, the values of its local variables are lost and the memory
used by these variables is freed and can be reclaimed.
➢ Variables that are declared with keyword Dim exist only as long as the procedure is
being executed.
VARIABLES
Dr. K. ADISESHA
16
Static Variable:
Static variables are not reinitialized each time Visual Invokes a procedure and
therefore retains or preserves value even when a procedure ends. These static variables
are also ideal for making controls alternately visible or invisible.
➢ A static variable is declared as given below.
Static intPermanent As Integer
➢ Variables have a lifetime in addition to scope.
➢ The value of a local variable can be preserved using the Static keyword.
Private Sub Command1_Click ( )
Static Counter As Integer
End Sub
VARIABLES
Dr. K. ADISESHA
17
Module Level Variable:
A module level variable is available to all the procedures in the module. They are
declared using the Public or the Private keyword.
If you declare a variable using a Private or a Dim statement in the declaration section
of a module—a standard BAS module, a form module, a class module, and so on.
➢ A Private module-level variables are visible only from within the module they belong to
and can't be accessed from the outside. these variables are useful for sharing data
among procedures in the same module:
Private LoginTime As Date ' A private module-level variable
➢ A Public module-level variable that can be accessed by all procedures in the module
to share data and that also can be accessed from outside the module.
VARIABLES
Dr. K. ADISESHA
18
Assigning Values to Variables:
After declaring various variables using Dim statements,we can assign values to
variables.
➢ Example:
❖ firstNumber=100
❖ secondNumber=firstNumber-99
❖ userName=“K Adisesha"
❖ userpass.Text = password
❖ Label1.Visible = True
❖ Command1.Visible = false
❖ Label4.Caption = textbox1.Text
❖ ThirdNumber = Val(usernum1.Text)
CONSTANTS
Dr. K. ADISESHA
19
Constants in Visual Basic:
Constant also store values, but as the name implies, those values remains
constant throughout the execution of an application.
➢ Using constants can make your code more readable by providing meaningful names
instead of numbers.
➢ There are a number of built –in constants in Visual Basic.
➢ There are two sources for constants:
❖ System-defined constants : are provided by applications and controls. Visual Basic
constants are listed in the Visual Basic (VB). Form1.WindowState=value
❖ User-defined constants: are declared using the Const statement. It is a space in
memory filled with fixed value that will not be changed.
Const constant_name = value
OPERATORS
Dr. K. ADISESHA
20
Operators in Visual Basic:
An operator is a special symbol which indicates a certain process is carried out.
Operators in programming languages are taken from mathematics.
➢ The operators are used to process data.
➢ Types of operators in Visual Basic:
❖ Arithmetical operators
❖ Relational operators
❖ Logical operators.
OPERATORS
Dr. K. ADISESHA
21
ARITHMETICAL OPERATORS:
Arithmetic operators are used to perform many of the familiar arithmetic operations that
involve the calculation of numeric values represented by literals, variables, other
expressions, function and property calls, and constants.
OPERATORS
Dr. K. ADISESHA
22
RELATIONAL OPERATORS:
Comparison operators are used for Decision Making or compare two expressions and
return a Boolean value that represents the relationship of their values.
➢ It uses If/Then structure
➢ Allows a program to make decision based on the truth or falsity of some expression
Condition:
➢ The expression in an If/Then structure
❖ If the condition is true, the statement in the body of the structure executes
➢ Conditions can be formed by using
❖ Equality operators
❖ Relational operators
OPERATORS
Dr. K. ADISESHA
23
RELATIONAL OPERATORS:
Comparison operators compare two expressions and return a Boolean value that
represents the relationship of their values. There are operators for comparing numeric
values, operators for comparing strings, and operators for comparing objects..
Operators Description Example Result
> Greater than 10>8 True
< Less than 10<8 False
>= Greater than or equal to 10>=8 True
<= Less than or equal to 10<=8 False
== Equal to 10==8 false
<> Not Equal to 10<>8 True
OPERATORS
Dr. K. ADISESHA
24
LOGICAL OPERATORS:
In addition to conditional operators, there are a few logical operators which offer added
power to the VB programs.
➢ Logical operators compare Boolean expressions and return a Boolean result.
➢ Some of these operators can also perform bitwise logical operations on integral
values.
Operators Description
OR OR Operation will be true if either of the operands is true
AND Operation will be true only if both the operands are true
XOR One side or other must be true but not both
NOT Negates true
BUILT IN FUNCTIONS
Dr. K. ADISESHA
25
BUILT IN FUNCTIONS:
Many built in functions are offered by Visual basic under various categories.
➢ These functions return a value.
➢ Types of built in functions in VB are:
❖ Date and Time function
❖ Format function
❖ String function
❖ Numeric function
BUILT IN FUNCTIONS
Dr. K. ADISESHA
26
BUILT IN FUNCTIONS:
Date and Time function: Use to store date and time values. A variable declared as date
type can store both date and time values and it can store date values 01/01/0100 up to
12/31/9999. Time between 0:00:00 and 23:59:59. It uses storage size of 8 bytes
Year Year(now)
Month Month(now)
Day Day(now)
Weekday Weekday(now)
Hour Hour(now)
Minute Minute(now)
Second Second(now)
BUILT IN FUNCTIONS
Dr. K. ADISESHA
27
BUILT IN FUNCTIONS:
Format function & String functions: Use to convert values in other formatted which are
convenient for user to use in application.
CONVERSION
Dr. K. ADISESHA
28
DATA TYPE CONVERSION:
Visual Basic functions either to convert a string into an integer or vice versa and many
more conversion functions.
Conversion To Function Description
Boolean Cbool The function Cbool converts any data type to Boolean 0 or 1
Byte Cbyte The function Cbyte converts any data type to Byte
Currency Ccur The function Ccur converts any data type to currency
Date Cdate The function Cdate converts any data type to date.
Decimals Cdec The function Cdec converts any data type to decimal
Value Cval The CVal function is used to convert string to double-
precision numbers.
Discussion
Dr. K. ADISESHA
29
Queries ?
Prof. K. Adisesha
9449081542

More Related Content

What's hot

VB PPT by ADI part-1.pdf
VB PPT by ADI part-1.pdfVB PPT by ADI part-1.pdf
VB PPT by ADI part-1.pdf
Prof. Dr. K. Adisesha
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++
Bharat Kalia
 
Methods in C#
Methods in C#Methods in C#
Methods in C#
Prasanna Kumar SM
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
Data types
Data typesData types
Data types
Syed Umair
 
Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#
Abid Kohistani
 
Constructor and destructor in oop
Constructor and destructor in oop Constructor and destructor in oop
Constructor and destructor in oop
Samad Qazi
 
Namespaces in C#
Namespaces in C#Namespaces in C#
Namespaces in C#
yogita kachve
 
Introduction to ADO.NET
Introduction to ADO.NETIntroduction to ADO.NET
Introduction to ADO.NET
rchakra
 
Vb tutorial
Vb tutorialVb tutorial
Vb tutorial
Saikarthik103212
 
VB PPT by ADI PART3.pdf
VB PPT by ADI PART3.pdfVB PPT by ADI PART3.pdf
VB PPT by ADI PART3.pdf
Prof. Dr. K. Adisesha
 
Variable scope ppt in vb6
Variable scope ppt in vb6Variable scope ppt in vb6
Variable scope ppt in vb6
AmanHooda4
 
Introduction to .NET Framework
Introduction to .NET FrameworkIntroduction to .NET Framework
Introduction to .NET Framework
Raghuveer Guthikonda
 
Keywords, identifiers and data type of vb.net
Keywords, identifiers and data type of vb.netKeywords, identifiers and data type of vb.net
Keywords, identifiers and data type of vb.net
Jaya Kumari
 
Pointer arithmetic in c
Pointer arithmetic in c Pointer arithmetic in c
Pointer arithmetic in c
sangrampatil81
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
Mahender Boda
 
Data types in C language
Data types in C languageData types in C language
Data types in C language
kashyap399
 
C# program structure
C# program structureC# program structure
Unit 9. Structure and Unions
Unit 9. Structure and UnionsUnit 9. Structure and Unions
Unit 9. Structure and Unions
Ashim Lamichhane
 
Control Structures in Visual Basic
Control Structures in  Visual BasicControl Structures in  Visual Basic
Control Structures in Visual Basic
Tushar Jain
 

What's hot (20)

VB PPT by ADI part-1.pdf
VB PPT by ADI part-1.pdfVB PPT by ADI part-1.pdf
VB PPT by ADI part-1.pdf
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++
 
Methods in C#
Methods in C#Methods in C#
Methods in C#
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
Data types
Data typesData types
Data types
 
Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#
 
Constructor and destructor in oop
Constructor and destructor in oop Constructor and destructor in oop
Constructor and destructor in oop
 
Namespaces in C#
Namespaces in C#Namespaces in C#
Namespaces in C#
 
Introduction to ADO.NET
Introduction to ADO.NETIntroduction to ADO.NET
Introduction to ADO.NET
 
Vb tutorial
Vb tutorialVb tutorial
Vb tutorial
 
VB PPT by ADI PART3.pdf
VB PPT by ADI PART3.pdfVB PPT by ADI PART3.pdf
VB PPT by ADI PART3.pdf
 
Variable scope ppt in vb6
Variable scope ppt in vb6Variable scope ppt in vb6
Variable scope ppt in vb6
 
Introduction to .NET Framework
Introduction to .NET FrameworkIntroduction to .NET Framework
Introduction to .NET Framework
 
Keywords, identifiers and data type of vb.net
Keywords, identifiers and data type of vb.netKeywords, identifiers and data type of vb.net
Keywords, identifiers and data type of vb.net
 
Pointer arithmetic in c
Pointer arithmetic in c Pointer arithmetic in c
Pointer arithmetic in c
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
 
Data types in C language
Data types in C languageData types in C language
Data types in C language
 
C# program structure
C# program structureC# program structure
C# program structure
 
Unit 9. Structure and Unions
Unit 9. Structure and UnionsUnit 9. Structure and Unions
Unit 9. Structure and Unions
 
Control Structures in Visual Basic
Control Structures in  Visual BasicControl Structures in  Visual Basic
Control Structures in Visual Basic
 

Similar to VB PPT by ADI PART2.pdf

VB PPT by ADI PART2.pdf
VB PPT by ADI PART2.pdfVB PPT by ADI PART2.pdf
VB PPT by ADI PART2.pdf
AdiseshaK
 
Ma3696 Lecture 3
Ma3696 Lecture 3Ma3696 Lecture 3
Ma3696 Lecture 3
Brunel University
 
Introduction to Visual Basic
Introduction to Visual Basic Introduction to Visual Basic
Qtp - Introduction to fundamentals of vbscript
Qtp - Introduction to fundamentals of vbscriptQtp - Introduction to fundamentals of vbscript
Qtp - Introduction to fundamentals of vbscript
Vibrant Technologies & Computers
 
Qtp classes-in-mumbai
Qtp classes-in-mumbaiQtp classes-in-mumbai
Qtp classes-in-mumbai
vibrantuser
 
Computer programming - variables constants operators expressions and statements
Computer programming - variables constants operators expressions and statementsComputer programming - variables constants operators expressions and statements
Computer programming - variables constants operators expressions and statements
John Paul Espino
 
Variables
VariablesVariables
Variables
Maha Saad
 
12.6-12.9.pptx
12.6-12.9.pptx12.6-12.9.pptx
12.6-12.9.pptx
WinterSnow16
 
Notes how to work with variables, constants and do calculations
Notes how to work with variables, constants and do calculationsNotes how to work with variables, constants and do calculations
Notes how to work with variables, constants and do calculations
William Olivier
 
Programming concepts By ZAK
Programming concepts By ZAKProgramming concepts By ZAK
Programming concepts By ZAK
Tabsheer Hasan
 
C programming session7
C programming  session7C programming  session7
C programming session7
Keroles karam khalil
 
C programming session7
C programming  session7C programming  session7
C programming session7
Keroles karam khalil
 
c#.pptx
c#.pptxc#.pptx
Standard coding practices
Standard coding practicesStandard coding practices
Standard coding practices
Anilkumar Patil
 
Visual Basics for Application
Visual Basics for Application Visual Basics for Application
Visual Basics for Application
Raghu nath
 
ASP.Net Technologies Part-2
ASP.Net Technologies Part-2ASP.Net Technologies Part-2
ASP.Net Technologies Part-2
Vasudev Sharma
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
Ajeet Kumar
 
Introduction to Programming Fundamentals 3.pdf
Introduction to Programming Fundamentals 3.pdfIntroduction to Programming Fundamentals 3.pdf
Introduction to Programming Fundamentals 3.pdf
AbrehamKassa
 
Unit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programmingUnit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programming
Abha Damani
 
Unit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical Expressions
Unit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical ExpressionsUnit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical Expressions
Unit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical Expressions
dubon07
 

Similar to VB PPT by ADI PART2.pdf (20)

VB PPT by ADI PART2.pdf
VB PPT by ADI PART2.pdfVB PPT by ADI PART2.pdf
VB PPT by ADI PART2.pdf
 
Ma3696 Lecture 3
Ma3696 Lecture 3Ma3696 Lecture 3
Ma3696 Lecture 3
 
Introduction to Visual Basic
Introduction to Visual Basic Introduction to Visual Basic
Introduction to Visual Basic
 
Qtp - Introduction to fundamentals of vbscript
Qtp - Introduction to fundamentals of vbscriptQtp - Introduction to fundamentals of vbscript
Qtp - Introduction to fundamentals of vbscript
 
Qtp classes-in-mumbai
Qtp classes-in-mumbaiQtp classes-in-mumbai
Qtp classes-in-mumbai
 
Computer programming - variables constants operators expressions and statements
Computer programming - variables constants operators expressions and statementsComputer programming - variables constants operators expressions and statements
Computer programming - variables constants operators expressions and statements
 
Variables
VariablesVariables
Variables
 
12.6-12.9.pptx
12.6-12.9.pptx12.6-12.9.pptx
12.6-12.9.pptx
 
Notes how to work with variables, constants and do calculations
Notes how to work with variables, constants and do calculationsNotes how to work with variables, constants and do calculations
Notes how to work with variables, constants and do calculations
 
Programming concepts By ZAK
Programming concepts By ZAKProgramming concepts By ZAK
Programming concepts By ZAK
 
C programming session7
C programming  session7C programming  session7
C programming session7
 
C programming session7
C programming  session7C programming  session7
C programming session7
 
c#.pptx
c#.pptxc#.pptx
c#.pptx
 
Standard coding practices
Standard coding practicesStandard coding practices
Standard coding practices
 
Visual Basics for Application
Visual Basics for Application Visual Basics for Application
Visual Basics for Application
 
ASP.Net Technologies Part-2
ASP.Net Technologies Part-2ASP.Net Technologies Part-2
ASP.Net Technologies Part-2
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
 
Introduction to Programming Fundamentals 3.pdf
Introduction to Programming Fundamentals 3.pdfIntroduction to Programming Fundamentals 3.pdf
Introduction to Programming Fundamentals 3.pdf
 
Unit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programmingUnit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programming
 
Unit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical Expressions
Unit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical ExpressionsUnit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical Expressions
Unit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical Expressions
 

More from Prof. Dr. K. Adisesha

Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
Prof. Dr. K. Adisesha
 
Operating System-4 "File Management" by Adi.pdf
Operating System-4 "File Management" by Adi.pdfOperating System-4 "File Management" by Adi.pdf
Operating System-4 "File Management" by Adi.pdf
Prof. Dr. K. Adisesha
 
Operating System-3 "Memory Management" by Adi.pdf
Operating System-3 "Memory Management" by Adi.pdfOperating System-3 "Memory Management" by Adi.pdf
Operating System-3 "Memory Management" by Adi.pdf
Prof. Dr. K. Adisesha
 
Operating System Concepts Part-1 by_Adi.pdf
Operating System Concepts Part-1 by_Adi.pdfOperating System Concepts Part-1 by_Adi.pdf
Operating System Concepts Part-1 by_Adi.pdf
Prof. Dr. K. Adisesha
 
Operating System-2_Process Managementby_Adi.pdf
Operating System-2_Process Managementby_Adi.pdfOperating System-2_Process Managementby_Adi.pdf
Operating System-2_Process Managementby_Adi.pdf
Prof. Dr. K. Adisesha
 
Software Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfSoftware Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdf
Prof. Dr. K. Adisesha
 
Software Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfSoftware Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdf
Prof. Dr. K. Adisesha
 
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfSoftware Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Prof. Dr. K. Adisesha
 
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfSoftware Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Prof. Dr. K. Adisesha
 
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfSoftware Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Prof. Dr. K. Adisesha
 
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfSoftware Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Prof. Dr. K. Adisesha
 
Computer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaComputer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. Adisesha
Prof. Dr. K. Adisesha
 
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaCCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
Prof. Dr. K. Adisesha
 
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaCCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
Prof. Dr. K. Adisesha
 
CCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaCCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. Adisesha
Prof. Dr. K. Adisesha
 
CCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfCCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdf
Prof. Dr. K. Adisesha
 
Introduction to Computers.pdf
Introduction to Computers.pdfIntroduction to Computers.pdf
Introduction to Computers.pdf
Prof. Dr. K. Adisesha
 
R_Programming.pdf
R_Programming.pdfR_Programming.pdf
R_Programming.pdf
Prof. Dr. K. Adisesha
 
Scholarship.pdf
Scholarship.pdfScholarship.pdf
Scholarship.pdf
Prof. Dr. K. Adisesha
 
Operating System-2 by Adi.pdf
Operating System-2 by Adi.pdfOperating System-2 by Adi.pdf
Operating System-2 by Adi.pdf
Prof. Dr. K. Adisesha
 

More from Prof. Dr. K. Adisesha (20)

Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
 
Operating System-4 "File Management" by Adi.pdf
Operating System-4 "File Management" by Adi.pdfOperating System-4 "File Management" by Adi.pdf
Operating System-4 "File Management" by Adi.pdf
 
Operating System-3 "Memory Management" by Adi.pdf
Operating System-3 "Memory Management" by Adi.pdfOperating System-3 "Memory Management" by Adi.pdf
Operating System-3 "Memory Management" by Adi.pdf
 
Operating System Concepts Part-1 by_Adi.pdf
Operating System Concepts Part-1 by_Adi.pdfOperating System Concepts Part-1 by_Adi.pdf
Operating System Concepts Part-1 by_Adi.pdf
 
Operating System-2_Process Managementby_Adi.pdf
Operating System-2_Process Managementby_Adi.pdfOperating System-2_Process Managementby_Adi.pdf
Operating System-2_Process Managementby_Adi.pdf
 
Software Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfSoftware Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdf
 
Software Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfSoftware Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdf
 
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfSoftware Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
 
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfSoftware Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
 
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfSoftware Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
 
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfSoftware Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
 
Computer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaComputer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. Adisesha
 
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaCCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
 
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaCCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
 
CCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaCCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. Adisesha
 
CCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfCCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdf
 
Introduction to Computers.pdf
Introduction to Computers.pdfIntroduction to Computers.pdf
Introduction to Computers.pdf
 
R_Programming.pdf
R_Programming.pdfR_Programming.pdf
R_Programming.pdf
 
Scholarship.pdf
Scholarship.pdfScholarship.pdf
Scholarship.pdf
 
Operating System-2 by Adi.pdf
Operating System-2 by Adi.pdfOperating System-2 by Adi.pdf
Operating System-2 by Adi.pdf
 

Recently uploaded

How to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in useHow to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in use
Celine George
 
BPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end examBPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end exam
sonukumargpnirsadhan
 
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptxContiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Kalna College
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
 
Accounting for Restricted Grants When and How To Record Properly
Accounting for Restricted Grants  When and How To Record ProperlyAccounting for Restricted Grants  When and How To Record Properly
Accounting for Restricted Grants When and How To Record Properly
TechSoup
 
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
Kalna College
 
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
220711130083 SUBHASHREE RAKSHIT  Internet resources for social science220711130083 SUBHASHREE RAKSHIT  Internet resources for social science
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
Kalna College
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
danielkiash986
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
blueshagoo1
 
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxxSimple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
RandolphRadicy
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
Steve Thomason
 
How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17
Celine George
 
220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx
Kalna College
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
giancarloi8888
 
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
ImMuslim
 
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
Nguyen Thanh Tu Collection
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
EduSkills OECD
 

Recently uploaded (20)

How to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in useHow to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in use
 
BPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end examBPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end exam
 
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptxContiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptx
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
 
Accounting for Restricted Grants When and How To Record Properly
Accounting for Restricted Grants  When and How To Record ProperlyAccounting for Restricted Grants  When and How To Record Properly
Accounting for Restricted Grants When and How To Record Properly
 
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
 
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
220711130083 SUBHASHREE RAKSHIT  Internet resources for social science220711130083 SUBHASHREE RAKSHIT  Internet resources for social science
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
 
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxxSimple-Present-Tense xxxxxxxxxxxxxxxxxxx
Simple-Present-Tense xxxxxxxxxxxxxxxxxxx
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
 
How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17
 
220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
 
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
 
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
 

VB PPT by ADI PART2.pdf

  • 3. INTRODUCTION Dr. K. ADISESHA 3 Programming using Visual Basic: Visual Basic uses building blocks such as Variables, Data Types, Procedures, Functions and Control Structures in its programming environment. This section concentrates on the programming fundamentals of Visual Basic with the blocks specified. ➢ MODULES : Code in Visual Basic is stored in the form of modules, which are of three type Form Modules, Standard Modules and Class Modules. ➢ Each module can contain: ❖ Declarations :May include constant, type, variable and DLL procedure declarations ❖ Procedures : A sub function, or property procedure that contain pieces of code that can be executed as a unit.
  • 4. DATA TYPES Dr. K. ADISESHA 4 Data types in Visual Basic: The compiler sets apart a number of bytes for each of the variable depending on the data type of holds Data types in Visual Basic ❖ Numeric ❖ String ❖ Date ❖ Boolean ❖ Variant
  • 5. Data type Size Range Byte 1 byte Byte Store integer values in the range of 0 - 255 Integer 2 bytes Integer Store integer values in the range of (-32,768) - (+ 32,767) Long 4 bytes Long Store integer values in the range of (- 2,147,483,468) - (+ 2,147,483,468) Single 4 bytes Single Store floating point value in the range of (-3.4x10-38) - (+ 3.4x1038) Double 8 bytes Double Store large floating value which exceeding the single data type value Currency 8 bytes Currency store monetary values. It supports 4 digits to the right of decimal point and 15 digits to the left Decimal 14 bytes Decimal stores value with 28 places to the right of the decimal; smallest non-zero number is +/-0.0000000000000000000000000001 DATA TYPES Dr. K. ADISESHA 5 ➢ Numeric Data type: The fundamental data types in Visual Basic including variant are integer, long, single, double, string, currency, byte and boolean.
  • 6. DATA TYPES Dr. K. ADISESHA 6 Data types : ➢ String: Use to store alphanumeric values. A variable length string can store approximately 4 billion characters. Uses storage size10 bytes + ➢ Date : Use to store date and time values. A variable declared as date type can store both date and time values and it can store date values 01/01/0100 up to 12/31/9999. It uses storage size of 8 bytes ➢ Boolean : Boolean data types hold either a true or false value. These are not stored as numeric values and cannot be used as such. Values are internally stored as -1 (True) and 0 (False) and any non-zero value is considered as true. Uses storage size of2 bytes ➢ Variant : In Visual Basic if we declare a variable without any data type by default the data type is assigned as variant data type.
  • 7. VARIABLES Dr. K. ADISESHA 7 Variables: Variables are the memory locations which are used to store values temporarily. A defined naming strategy has to be followed while naming a variable. ➢ A variable name must begin with an alphabet letter and should not exceed 255 characters. ➢ It must be unique within the same scope. ➢ The different ways of declaring variables in Visual Basic are listed below: ❖ Explicit Declaration ❖ Implicit Declaration ❖ Using Option Explicit statement
  • 8. VARIABLES Dr. K. ADISESHA 8 Variables: Variables are the memory locations which are used to store values temporarily. A defined naming strategy has to be followed while naming a variable. ➢ The following are the rules when naming the variables in Visual Basic: ❖ It must be less than 255 characters ❖ No spacing is allowed ❖ It must not begin with a number ❖ Period is not permitted ❖ Cannot use exclamation mark (!), or the characters @, &, $, # ❖ Cannot repeat names within the same level of scope.
  • 9. VARIABLES Dr. K. ADISESHA 9 Explicit variables declaration : Declaring a variable tells Visual Basic to reserve space in memory. to have more control over the variables, it is advisable to declare them explicitly. ➢ The variable can have different names and different types of values. ➢ The dim is keyword in visual Basic and has language specific meaning. ➢ Syntax for Declaring Variable Dim VaribaleName As DataType ➢ Example : Dim Regno as integer Dim Myname as string
  • 10. VARIABLES Dr. K. ADISESHA 10 Implicit variables declaration : Visual Basic encounters a new variable, it assigns the default variable type and value. This is called implicit declaration. Though this type of declaration is easier for the user. ➢ It may be convenient to declare variables implicitly, but it can lead to errors that may not be recognized at run time ➢ Syntax for Declaring Variable Dim str1,str2 Str1= “Implicit Declaration” Str2= Intcount + 1
  • 11. VARIABLES Dr. K. ADISESHA 11 Option Explicit variables declaration : This forces the user to declare all the variables. The Option Explicit statement checks in the module for usage of any undeclared variables and reports an error to the user. ➢ The user can thus rectify the error on seeing this error message. ➢ The Option Explicit statement can be explicitly placed in the general declaration section of each module using the following steps. ❖ Click Options item in the Tools menu ❖ Click the Editor tab in the Options dialog box ❖ Check Require Variable Declaration option and then click the OK button
  • 12. VARIABLES Dr. K. ADISESHA 12 Example: Program to find sum and average of two numbers
  • 13. VARIABLES Dr. K. ADISESHA 13 Scope of the variable: The scope of variable determines where you can access that variable in your code. ➢ If a variable is in scope you can read or set its value. ➢ If it is out of scope you will not be able to access it. ➢ Types of scope for variables in visual basic ❖ Global scope: Global variables are in scope anywhere in your application ❖ Module scope :Module level variables are in scope anywhere within the module where they are declared ❖ Local scope : Local variables are only in scope within the procedure where they are declared.
  • 14. Variables Dr. K. ADISESHA 14 Scope of the variable: Types of scope for variables in visual basic ➢ Local Variables: A local variable is one that is declared inside a procedure. This variable is only available to the code inside the procedure. Dim sum As Integer ➢ Static Variables: Static variables are not reinitialized each time Visual basic invokes a procedure and therefore retains or preserves value even when a procedure ends. Static intPermanent As Integer ➢ Module Level Variables: A module level variable is available to all the procedures in the module. They are declared using the Public or the Private keyword. these variables are useful for sharing data among procedures in the same module. Public CustomerName As String
  • 15. VARIABLES Dr. K. ADISESHA 15 Local Variables: A local variable is one that is declared inside a procedure. This variable is only available to the code inside the procedure and can be declared using the Dim statements. Dim sum As Integer ➢ The local variables exist as long as the procedure in which they are declared, is executing. ➢ Once a procedure is executed, the values of its local variables are lost and the memory used by these variables is freed and can be reclaimed. ➢ Variables that are declared with keyword Dim exist only as long as the procedure is being executed.
  • 16. VARIABLES Dr. K. ADISESHA 16 Static Variable: Static variables are not reinitialized each time Visual Invokes a procedure and therefore retains or preserves value even when a procedure ends. These static variables are also ideal for making controls alternately visible or invisible. ➢ A static variable is declared as given below. Static intPermanent As Integer ➢ Variables have a lifetime in addition to scope. ➢ The value of a local variable can be preserved using the Static keyword. Private Sub Command1_Click ( ) Static Counter As Integer End Sub
  • 17. VARIABLES Dr. K. ADISESHA 17 Module Level Variable: A module level variable is available to all the procedures in the module. They are declared using the Public or the Private keyword. If you declare a variable using a Private or a Dim statement in the declaration section of a module—a standard BAS module, a form module, a class module, and so on. ➢ A Private module-level variables are visible only from within the module they belong to and can't be accessed from the outside. these variables are useful for sharing data among procedures in the same module: Private LoginTime As Date ' A private module-level variable ➢ A Public module-level variable that can be accessed by all procedures in the module to share data and that also can be accessed from outside the module.
  • 18. VARIABLES Dr. K. ADISESHA 18 Assigning Values to Variables: After declaring various variables using Dim statements,we can assign values to variables. ➢ Example: ❖ firstNumber=100 ❖ secondNumber=firstNumber-99 ❖ userName=“K Adisesha" ❖ userpass.Text = password ❖ Label1.Visible = True ❖ Command1.Visible = false ❖ Label4.Caption = textbox1.Text ❖ ThirdNumber = Val(usernum1.Text)
  • 19. CONSTANTS Dr. K. ADISESHA 19 Constants in Visual Basic: Constant also store values, but as the name implies, those values remains constant throughout the execution of an application. ➢ Using constants can make your code more readable by providing meaningful names instead of numbers. ➢ There are a number of built –in constants in Visual Basic. ➢ There are two sources for constants: ❖ System-defined constants : are provided by applications and controls. Visual Basic constants are listed in the Visual Basic (VB). Form1.WindowState=value ❖ User-defined constants: are declared using the Const statement. It is a space in memory filled with fixed value that will not be changed. Const constant_name = value
  • 20. OPERATORS Dr. K. ADISESHA 20 Operators in Visual Basic: An operator is a special symbol which indicates a certain process is carried out. Operators in programming languages are taken from mathematics. ➢ The operators are used to process data. ➢ Types of operators in Visual Basic: ❖ Arithmetical operators ❖ Relational operators ❖ Logical operators.
  • 21. OPERATORS Dr. K. ADISESHA 21 ARITHMETICAL OPERATORS: Arithmetic operators are used to perform many of the familiar arithmetic operations that involve the calculation of numeric values represented by literals, variables, other expressions, function and property calls, and constants.
  • 22. OPERATORS Dr. K. ADISESHA 22 RELATIONAL OPERATORS: Comparison operators are used for Decision Making or compare two expressions and return a Boolean value that represents the relationship of their values. ➢ It uses If/Then structure ➢ Allows a program to make decision based on the truth or falsity of some expression Condition: ➢ The expression in an If/Then structure ❖ If the condition is true, the statement in the body of the structure executes ➢ Conditions can be formed by using ❖ Equality operators ❖ Relational operators
  • 23. OPERATORS Dr. K. ADISESHA 23 RELATIONAL OPERATORS: Comparison operators compare two expressions and return a Boolean value that represents the relationship of their values. There are operators for comparing numeric values, operators for comparing strings, and operators for comparing objects.. Operators Description Example Result > Greater than 10>8 True < Less than 10<8 False >= Greater than or equal to 10>=8 True <= Less than or equal to 10<=8 False == Equal to 10==8 false <> Not Equal to 10<>8 True
  • 24. OPERATORS Dr. K. ADISESHA 24 LOGICAL OPERATORS: In addition to conditional operators, there are a few logical operators which offer added power to the VB programs. ➢ Logical operators compare Boolean expressions and return a Boolean result. ➢ Some of these operators can also perform bitwise logical operations on integral values. Operators Description OR OR Operation will be true if either of the operands is true AND Operation will be true only if both the operands are true XOR One side or other must be true but not both NOT Negates true
  • 25. BUILT IN FUNCTIONS Dr. K. ADISESHA 25 BUILT IN FUNCTIONS: Many built in functions are offered by Visual basic under various categories. ➢ These functions return a value. ➢ Types of built in functions in VB are: ❖ Date and Time function ❖ Format function ❖ String function ❖ Numeric function
  • 26. BUILT IN FUNCTIONS Dr. K. ADISESHA 26 BUILT IN FUNCTIONS: Date and Time function: Use to store date and time values. A variable declared as date type can store both date and time values and it can store date values 01/01/0100 up to 12/31/9999. Time between 0:00:00 and 23:59:59. It uses storage size of 8 bytes Year Year(now) Month Month(now) Day Day(now) Weekday Weekday(now) Hour Hour(now) Minute Minute(now) Second Second(now)
  • 27. BUILT IN FUNCTIONS Dr. K. ADISESHA 27 BUILT IN FUNCTIONS: Format function & String functions: Use to convert values in other formatted which are convenient for user to use in application.
  • 28. CONVERSION Dr. K. ADISESHA 28 DATA TYPE CONVERSION: Visual Basic functions either to convert a string into an integer or vice versa and many more conversion functions. Conversion To Function Description Boolean Cbool The function Cbool converts any data type to Boolean 0 or 1 Byte Cbyte The function Cbyte converts any data type to Byte Currency Ccur The function Ccur converts any data type to currency Date Cdate The function Cdate converts any data type to date. Decimals Cdec The function Cdec converts any data type to decimal Value Cval The CVal function is used to convert string to double- precision numbers.
  • 29. Discussion Dr. K. ADISESHA 29 Queries ? Prof. K. Adisesha 9449081542