SlideShare a Scribd company logo
15
Most read
22
Most read
23
Most read
ARRAYS
What is an array?
• We know very well that a variable is a container to store a value.
Sometimes, developers are in a position to hold more than one value
in a single variable at a time. When a series of values is stored in a
single variable, then it is known as an array variable.
CREATING ARRAYS
• We can create arrays several ways, depending on whether they are
static or dynamic.
• Static arrays - Static arrays stay a fixed size throughout their lifetime—
that is, the index size remains constant. Thus, when we create a static
array, we must know how many items the array will contain
throughout its lifetime.
• Dynamic arrays – Suppose if we don't know the number of items or
don’t know that the array's index size will change, we need to create a
dynamic array. Dynamic arrays don't have a fixed index size. We can
increase or decrease the index size at any time.
Array Declaration and Assigning Values to an Array
Example 1:
option explicit
dim arr(3)
arr(0)=1
arr(1)="2"
arr(2)="sun"
arr(3) = #10/07/2013#
msgbox arr(0)
msgbox arr(1)
msgbox arr(2)
msgbox arr(3)
Example 2:
option explicit
Dim arr
arr=array("5",100,45,464)
msgbox arr(0)
msgbox arr(1)
msgbox arr(2)
msgbox arr(3)
Multi-Dimension Arrays
• Arrays are not just limited to single dimension and can have a maximum of 60 dimensions. Two-dimension
arrays are the most commonly used ones.
Example:
Option explicit
Dim arr(1,2) //2 rows and 3 columns
arr(0,0) = "A"
arr(0,1) = "B"
arr(0,2) = "C"
arr(1,0) = "Dr"
arr(1,1) = "E"
arr(1,2) = "F"
msgbox arr(0,0)
msgbox arr(0,1)
msgbox arr(0,2)
msgbox arr(1,0)
msgbox arr(1,1)
msgbox arr(1,2)
ReDim Statement
• ReDim Statement is used to declare dynamic-array variables and allocate or reallocate storage space.
Example:
option explicit
dim arr()
redim arr(5)
arr(0)=1
arr(1)=2
arr(2)=3
arr(3)=4
arr(4)=5
redim preserve arr(10)
arr(6)=7
msgbox arr(0)
msgbox arr(1)
msgbox arr(6)
redim preserve arr(4)
msgbox arr(0)
msgbox arr(1)
msgbox arr(2)
msgbox arr(3)
msgbox arr(4)
Array Methods
LBound Function
• The LBound Function returns the smallest subscript of the specified array.
Hence, LBound of an array is ZERO.
Example:
option explicit
dim arr(5)
arr(0)=1
arr(1)=2
arr(2)=3
arr(3)=4
arr(4)=5
msgbox lbound(arr)
UBound Function
The UBound Function returns the Largest subscript of the specified
array. Hence, this value corresponds to the size of the array.
Example:
option explicit
dim arr(5)
arr(0)=1
arr(1)=2
arr(2)=3
arr(3)=4
arr(4)=5
msgbox ubound(arr)
Split Function
• A Split Function returns an array that contains a specific number of values
split based on a Delimiter.
Example:
option explicit
dim arr,b,c,i
arr=split("sun & technology & integrators","&")
b=ubound(arr)
for i=0 to b
msgbox arr(i)
next
Join Function
• A Function, which returns a String that contains a specified number of
substrings in an array. This is an exact opposite function of Split Method.
Example:
option explicit
dim arr,b,c
arr=array("sun","technology","integrators")
b=join(arr)
msgbox b
c=join(arr,0)
msgbox c
Filter Function
A Filter Function, which returns a zero-based array that contains a subset of a
string array based on a specific filter criteria.
Example:
option explicit
Dim MyIndex
Dim MyArray (3)
MyArray(0) = "Sunday"
MyArray(1) = "Monday"
MyArray(2) = "Tuesday"
MyIndex = Filter(MyArray, "Mon")
msgbox myindex(0)
IsArray Function
The IsArray Function returns a Boolean value that indicates whether or NOT the
specified input variable is an array variable.
Example:
option explicit
dim a,b
a=array("Red","Blue","Yellow")
b = "12345"
msgbox isarray(a)
msgbox isarray(b)
Erase Function
The Erase Function is used to reset the values of fixed size arrays and free the memory of the
dynamic arrays.
Example:
option explicit
dim a(2)
a(0)="hello"
a(1)=22
a(2)=08
msgbox a(0)
msgbox a(1)
msgbox a(2)
erase a
msgbox a(0)
msgbox a(1)
msgbox a(2)
FUNCTIONS
What is a Function?
A function is a group of reusable code which can be called anywhere in your
program. This eliminates the need of writing same code over and over again.
This will enable programmers to divide a big program into a number of small and
manageable functions.
• Function Definition
Before we use a function, we need to define that particular function. The most
common way to define a function in VBScript is by using the Function keyword,
followed by a unique function name and it may or may not carry a list of
parameters and a statement with an End Function keyword
Example 1:
option explicit
Function Hello()
msgbox("Hello")
End Function
call hello()
Example2:
option explicit
Function Hello(name,age)
msgbox( name & " is " & age & " years old.")
End Function
call hello("vb",4)
Example3:
option explicit
Function sum(number1,number2)
sum = number1 + number2
End Function
Dim total
total = sum(100,9)
msgbox total
Sub-Procedures
Sub-Procedures are similar to functions but there are few differences.
• Sub-procedures DONOT Return a value while functions may or may not return
a value.
• Sub-procedures Can be called without call keyword.
• Sub-procedures are always enclosed within Sub and End Sub statements.
Example:
option explicit
sub Hello()
msgbox("Hello")
End sub
hello()
VBScript ByVal Parameters:
If ByVal is specified, then the arguments are sent as byvalue when the function or
procedure is called.
Example:
option explicit
Function fnadd(Byval num1, Byval num2)
num1 = 4
num2 = 5
End Function
Dim x,y,res
x=6
y=4
res= fnadd(x,y)
msgbox x
msgbox y
VBScript ByRef Parameters
If ByRef is specified, then the arguments are sent as a reference when the function or
procedure is called.
Example:
option explicit
Function fnadd(byRef num1,ByRef num2)
num1 = 4
num2 = 5
End Function
Dim x,y,res
x=6
y=4
res= fnadd(x,y)
msgbox x
msgbox y

More Related Content

PPTX
Strings in C language
P M Patil
 
PPTX
Event Handling in java
Google
 
PPTX
bus and memory tranfer (computer organaization)
Siddhi Viradiya
 
PDF
Applets
Prabhakaran V M
 
PDF
Loops and conditional statements
Saad Sheikh
 
PPTX
Arrays in c
Jeeva Nanthini
 
PPTX
arrays and pointers
Samiksha Pun
 
PPTX
Introduction to Array ppt
sandhya yadav
 
Strings in C language
P M Patil
 
Event Handling in java
Google
 
bus and memory tranfer (computer organaization)
Siddhi Viradiya
 
Loops and conditional statements
Saad Sheikh
 
Arrays in c
Jeeva Nanthini
 
arrays and pointers
Samiksha Pun
 
Introduction to Array ppt
sandhya yadav
 

What's hot (20)

PPTX
Array in c programming
Mazharul Islam
 
PPTX
Inheritance in java
Tech_MX
 
PPTX
Dynamic memory allocation in c
lavanya marichamy
 
PPTX
Presentation on array
topu93
 
PPS
Java Exception handling
kamal kotecha
 
PPTX
Classes, objects in JAVA
Abhilash Nair
 
PPTX
Pointers in c++
Vineeta Garg
 
PPTX
Dynamic memory allocation
Viji B
 
PPTX
structured programming
Ahmad54321
 
PPT
Bus and Memory transfer
mahesh kumar prajapat
 
PPTX
Branching statements
ArunMK17
 
PPTX
C if else
Ritwik Das
 
PPT
Iteration
Liam Dunphy
 
PPTX
Storage classes in C
Self employed
 
PPTX
While , For , Do-While Loop
Abhishek Choksi
 
PPT
Variables in C Programming
programming9
 
PPTX
Object Oriented Programming Concepts for beginners
Vibhawa Nirmal
 
PPTX
Java exception handling
BHUVIJAYAVELU
 
PPTX
Storage classes in c language
tanmaymodi4
 
PPS
Packages and inbuilt classes of java
kamal kotecha
 
Array in c programming
Mazharul Islam
 
Inheritance in java
Tech_MX
 
Dynamic memory allocation in c
lavanya marichamy
 
Presentation on array
topu93
 
Java Exception handling
kamal kotecha
 
Classes, objects in JAVA
Abhilash Nair
 
Pointers in c++
Vineeta Garg
 
Dynamic memory allocation
Viji B
 
structured programming
Ahmad54321
 
Bus and Memory transfer
mahesh kumar prajapat
 
Branching statements
ArunMK17
 
C if else
Ritwik Das
 
Iteration
Liam Dunphy
 
Storage classes in C
Self employed
 
While , For , Do-While Loop
Abhishek Choksi
 
Variables in C Programming
programming9
 
Object Oriented Programming Concepts for beginners
Vibhawa Nirmal
 
Java exception handling
BHUVIJAYAVELU
 
Storage classes in c language
tanmaymodi4
 
Packages and inbuilt classes of java
kamal kotecha
 
Ad

Viewers also liked (12)

PPTX
D.O. 36 S. 2016
Jayhaley Ana
 
PPTX
Un approccio civile al capitalismo fra utopia e realtà
Assocamerestero e le Camere di Commercio Italiane all’Estero (CCIE)
 
PDF
에이스트레이더 월간 마케팅 보고서_초중고교육 온라인 마케팅 동향
ACE Trader
 
PPTX
3Com CENTRO
savomir
 
PDF
Data Structure (Static Array)
Adam Mukharil Bachtiar
 
PPTX
QTest
Sun Technlogies
 
PPT
Software testing
Rakshitha Raviprakash
 
PPTX
Selenium
Rakshitha Raviprakash
 
PPTX
Extended Finite State Machine - EFSM
Sun Technlogies
 
PPTX
Sikuli
Sun Technlogies
 
PPTX
Devops
Sun Technlogies
 
PPTX
Jira
Sun Technlogies
 
D.O. 36 S. 2016
Jayhaley Ana
 
Un approccio civile al capitalismo fra utopia e realtà
Assocamerestero e le Camere di Commercio Italiane all’Estero (CCIE)
 
에이스트레이더 월간 마케팅 보고서_초중고교육 온라인 마케팅 동향
ACE Trader
 
3Com CENTRO
savomir
 
Data Structure (Static Array)
Adam Mukharil Bachtiar
 
Software testing
Rakshitha Raviprakash
 
Extended Finite State Machine - EFSM
Sun Technlogies
 
Ad

Similar to Array and functions (20)

DOCX
VBScript Functions procedures and arrays.docx
Ramakrishna Reddy Bijjam
 
DOCX
Arrays in VbScript
Nilanjan Saha
 
PPTX
VB Script
Satish Sukumaran
 
PPTX
Basic vbscript for qtp
Cuong Tran Van
 
PPT
Chapter 08
Terry Yoast
 
PPTX
Arrays
kuldeep94
 
PDF
procedures and arrays
DivyaR219113
 
PPTX
VISUAL BASIC 6 - CONTROLS AND DECLARATIONS
Suraj Kumar
 
PPTX
Qtp vb scripting
Bharath Sannadi
 
PPT
QTP Presentation2
vucevic
 
PPT
VB Script Overview
Praveen Gorantla
 
PDF
7400354 vbscript-in-qtp
Bharath003
 
PPTX
Vbscript
Abhishek Kesharwani
 
PPT
Vb script
mcatahir947
 
PPT
VB_ERROR CONTROL_FILE HANDLING.ppt
BhuvanaR13
 
PPT
September 9 2008
napzpogi
 
DOCX
VBS control structures for if do whilw.docx
Ramakrishna Reddy Bijjam
 
PPT
Arrays
Juhi Kumari
 
PDF
Vb6 ch.8-3 cci
Fahim Khan
 
VBScript Functions procedures and arrays.docx
Ramakrishna Reddy Bijjam
 
Arrays in VbScript
Nilanjan Saha
 
VB Script
Satish Sukumaran
 
Basic vbscript for qtp
Cuong Tran Van
 
Chapter 08
Terry Yoast
 
Arrays
kuldeep94
 
procedures and arrays
DivyaR219113
 
VISUAL BASIC 6 - CONTROLS AND DECLARATIONS
Suraj Kumar
 
Qtp vb scripting
Bharath Sannadi
 
QTP Presentation2
vucevic
 
VB Script Overview
Praveen Gorantla
 
7400354 vbscript-in-qtp
Bharath003
 
Vb script
mcatahir947
 
VB_ERROR CONTROL_FILE HANDLING.ppt
BhuvanaR13
 
September 9 2008
napzpogi
 
VBS control structures for if do whilw.docx
Ramakrishna Reddy Bijjam
 
Arrays
Juhi Kumari
 
Vb6 ch.8-3 cci
Fahim Khan
 

More from Sun Technlogies (14)

PPTX
Silk Performer Presentation v1
Sun Technlogies
 
PPT
Selenium
Sun Technlogies
 
PPTX
Selenium web driver
Sun Technlogies
 
PPTX
XPATH
Sun Technlogies
 
PPTX
Path Testing
Sun Technlogies
 
PPTX
Maven and ANT
Sun Technlogies
 
PPTX
HTML, CSS and Java Scripts Basics
Sun Technlogies
 
PPTX
Jmeter
Sun Technlogies
 
PPTX
Javascript
Sun Technlogies
 
PPTX
HyperText Markup Language - HTML
Sun Technlogies
 
PPTX
Cascading Style Sheets - CSS
Sun Technlogies
 
PPTX
Core java
Sun Technlogies
 
PPTX
Automation Testing
Sun Technlogies
 
PPTX
Mobile Application Testing
Sun Technlogies
 
Silk Performer Presentation v1
Sun Technlogies
 
Selenium
Sun Technlogies
 
Selenium web driver
Sun Technlogies
 
Path Testing
Sun Technlogies
 
Maven and ANT
Sun Technlogies
 
HTML, CSS and Java Scripts Basics
Sun Technlogies
 
Javascript
Sun Technlogies
 
HyperText Markup Language - HTML
Sun Technlogies
 
Cascading Style Sheets - CSS
Sun Technlogies
 
Core java
Sun Technlogies
 
Automation Testing
Sun Technlogies
 
Mobile Application Testing
Sun Technlogies
 

Recently uploaded (20)

PPTX
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
PDF
Emergency Mustering solutions – A Brief overview
Personnel Tracking
 
PDF
Microsoft Teams Essentials; The pricing and the versions_PDF.pdf
Q-Advise
 
PPTX
Why Use Open Source Reporting Tools for Business Intelligence.pptx
Varsha Nayak
 
PPT
Overview of Oracle Receivables Process.ppt
nbvreddy229
 
DOCX
The Five Best AI Cover Tools in 2025.docx
aivoicelabofficial
 
PDF
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
Hironori Washizaki
 
PDF
Winning Business in a Slowing Economy, How CPQ helps Manufacturers Protect Ma...
systemscincom
 
PDF
The Future of Smart Factories Why Embedded Analytics Leads the Way
Varsha Nayak
 
PPTX
introduction to dart --- Section one .pptx
marknaiem92
 
PDF
How to Seamlessly Integrate Salesforce Data Cloud with Marketing Cloud.pdf
NSIQINFOTECH
 
PPTX
Materi-Enum-and-Record-Data-Type (1).pptx
RanuFajar1
 
PDF
Why Should Businesses Extract Cuisine Types Data from Multiple U.S. Food Apps...
devilbrown689
 
PDF
Rise With SAP partner in Mumbai.........
pts464036
 
PPT
Order to Cash Lifecycle Overview R12 .ppt
nbvreddy229
 
PDF
Build Multi-agent using Agent Development Kit
FadyIbrahim23
 
PDF
Comprehensive Salesforce Implementation Services.pdf
VALiNTRY360
 
PPTX
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
PDF
Become an Agentblazer Champion Challenge
Dele Amefo
 
PDF
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
Emergency Mustering solutions – A Brief overview
Personnel Tracking
 
Microsoft Teams Essentials; The pricing and the versions_PDF.pdf
Q-Advise
 
Why Use Open Source Reporting Tools for Business Intelligence.pptx
Varsha Nayak
 
Overview of Oracle Receivables Process.ppt
nbvreddy229
 
The Five Best AI Cover Tools in 2025.docx
aivoicelabofficial
 
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
Hironori Washizaki
 
Winning Business in a Slowing Economy, How CPQ helps Manufacturers Protect Ma...
systemscincom
 
The Future of Smart Factories Why Embedded Analytics Leads the Way
Varsha Nayak
 
introduction to dart --- Section one .pptx
marknaiem92
 
How to Seamlessly Integrate Salesforce Data Cloud with Marketing Cloud.pdf
NSIQINFOTECH
 
Materi-Enum-and-Record-Data-Type (1).pptx
RanuFajar1
 
Why Should Businesses Extract Cuisine Types Data from Multiple U.S. Food Apps...
devilbrown689
 
Rise With SAP partner in Mumbai.........
pts464036
 
Order to Cash Lifecycle Overview R12 .ppt
nbvreddy229
 
Build Multi-agent using Agent Development Kit
FadyIbrahim23
 
Comprehensive Salesforce Implementation Services.pdf
VALiNTRY360
 
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
Become an Agentblazer Champion Challenge
Dele Amefo
 
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 

Array and functions

  • 2. What is an array? • We know very well that a variable is a container to store a value. Sometimes, developers are in a position to hold more than one value in a single variable at a time. When a series of values is stored in a single variable, then it is known as an array variable.
  • 3. CREATING ARRAYS • We can create arrays several ways, depending on whether they are static or dynamic. • Static arrays - Static arrays stay a fixed size throughout their lifetime— that is, the index size remains constant. Thus, when we create a static array, we must know how many items the array will contain throughout its lifetime. • Dynamic arrays – Suppose if we don't know the number of items or don’t know that the array's index size will change, we need to create a dynamic array. Dynamic arrays don't have a fixed index size. We can increase or decrease the index size at any time.
  • 4. Array Declaration and Assigning Values to an Array Example 1: option explicit dim arr(3) arr(0)=1 arr(1)="2" arr(2)="sun" arr(3) = #10/07/2013# msgbox arr(0) msgbox arr(1) msgbox arr(2) msgbox arr(3)
  • 5. Example 2: option explicit Dim arr arr=array("5",100,45,464) msgbox arr(0) msgbox arr(1) msgbox arr(2) msgbox arr(3)
  • 6. Multi-Dimension Arrays • Arrays are not just limited to single dimension and can have a maximum of 60 dimensions. Two-dimension arrays are the most commonly used ones. Example: Option explicit Dim arr(1,2) //2 rows and 3 columns arr(0,0) = "A" arr(0,1) = "B" arr(0,2) = "C" arr(1,0) = "Dr" arr(1,1) = "E" arr(1,2) = "F" msgbox arr(0,0) msgbox arr(0,1) msgbox arr(0,2) msgbox arr(1,0) msgbox arr(1,1) msgbox arr(1,2)
  • 7. ReDim Statement • ReDim Statement is used to declare dynamic-array variables and allocate or reallocate storage space. Example: option explicit dim arr() redim arr(5) arr(0)=1 arr(1)=2 arr(2)=3 arr(3)=4 arr(4)=5 redim preserve arr(10) arr(6)=7 msgbox arr(0) msgbox arr(1) msgbox arr(6) redim preserve arr(4) msgbox arr(0) msgbox arr(1) msgbox arr(2) msgbox arr(3) msgbox arr(4)
  • 8. Array Methods LBound Function • The LBound Function returns the smallest subscript of the specified array. Hence, LBound of an array is ZERO. Example: option explicit dim arr(5) arr(0)=1 arr(1)=2 arr(2)=3 arr(3)=4 arr(4)=5 msgbox lbound(arr)
  • 9. UBound Function The UBound Function returns the Largest subscript of the specified array. Hence, this value corresponds to the size of the array. Example: option explicit dim arr(5) arr(0)=1 arr(1)=2 arr(2)=3 arr(3)=4 arr(4)=5 msgbox ubound(arr)
  • 10. Split Function • A Split Function returns an array that contains a specific number of values split based on a Delimiter. Example: option explicit dim arr,b,c,i arr=split("sun & technology & integrators","&") b=ubound(arr) for i=0 to b msgbox arr(i) next
  • 11. Join Function • A Function, which returns a String that contains a specified number of substrings in an array. This is an exact opposite function of Split Method. Example: option explicit dim arr,b,c arr=array("sun","technology","integrators") b=join(arr) msgbox b c=join(arr,0) msgbox c
  • 12. Filter Function A Filter Function, which returns a zero-based array that contains a subset of a string array based on a specific filter criteria. Example: option explicit Dim MyIndex Dim MyArray (3) MyArray(0) = "Sunday" MyArray(1) = "Monday" MyArray(2) = "Tuesday" MyIndex = Filter(MyArray, "Mon") msgbox myindex(0)
  • 13. IsArray Function The IsArray Function returns a Boolean value that indicates whether or NOT the specified input variable is an array variable. Example: option explicit dim a,b a=array("Red","Blue","Yellow") b = "12345" msgbox isarray(a) msgbox isarray(b)
  • 14. Erase Function The Erase Function is used to reset the values of fixed size arrays and free the memory of the dynamic arrays. Example: option explicit dim a(2) a(0)="hello" a(1)=22 a(2)=08 msgbox a(0) msgbox a(1) msgbox a(2) erase a msgbox a(0) msgbox a(1) msgbox a(2)
  • 16. What is a Function? A function is a group of reusable code which can be called anywhere in your program. This eliminates the need of writing same code over and over again. This will enable programmers to divide a big program into a number of small and manageable functions. • Function Definition Before we use a function, we need to define that particular function. The most common way to define a function in VBScript is by using the Function keyword, followed by a unique function name and it may or may not carry a list of parameters and a statement with an End Function keyword
  • 17. Example 1: option explicit Function Hello() msgbox("Hello") End Function call hello()
  • 18. Example2: option explicit Function Hello(name,age) msgbox( name & " is " & age & " years old.") End Function call hello("vb",4)
  • 19. Example3: option explicit Function sum(number1,number2) sum = number1 + number2 End Function Dim total total = sum(100,9) msgbox total
  • 20. Sub-Procedures Sub-Procedures are similar to functions but there are few differences. • Sub-procedures DONOT Return a value while functions may or may not return a value. • Sub-procedures Can be called without call keyword. • Sub-procedures are always enclosed within Sub and End Sub statements.
  • 22. VBScript ByVal Parameters: If ByVal is specified, then the arguments are sent as byvalue when the function or procedure is called. Example: option explicit Function fnadd(Byval num1, Byval num2) num1 = 4 num2 = 5 End Function Dim x,y,res x=6 y=4 res= fnadd(x,y) msgbox x msgbox y
  • 23. VBScript ByRef Parameters If ByRef is specified, then the arguments are sent as a reference when the function or procedure is called. Example: option explicit Function fnadd(byRef num1,ByRef num2) num1 = 4 num2 = 5 End Function Dim x,y,res x=6 y=4 res= fnadd(x,y) msgbox x msgbox y