SlideShare a Scribd company logo
BEST-CORPORATE-TRAINING-
CLASSES-IN-M
UM
BAI
VIBRANT TECHNOLOGIES
&
COM
PUTERS, VASHI.
1VIBRANT TECHNOLOGIES & COMPUTERS
Vbscript fundamentals.
Variant subtypes.
Variables.
Option Explicit statement.
Keywords.
Scope and liftime of variables.
Dim, Private and Public statements.
Rem statement.
2VIBRANT TECHNOLOGIES & COMPUTERS
WHAT IS VBSCRIPT?
A Safe subset of visual basic
The VBScript Code is case Insensitive.
Microsoft Visual Basic Scripting Edition brings active
scripting to a wide variety of environments,
including Web client scripting in Microsoft Internet
Explorer and Web server scripting in Microsoft
Internet Information Service (IIS).
3VIBRANT TECHNOLOGIES & COMPUTERS
MICROSOFT®
SCRIPT TIMELINE
4
Internet
Explorer 3.0
8/96
Version
1.0
Version
2.0
IIS 2
12/96
Internet
Explorer 4.0
8/97
Version
3.0
Windows
98
Version
3.1
Version
4.0
Version
5.0
Visual
Studio 6
Internet
Explorer 5.0
Win NT 5.0
Note: QuickTest uses VBScript 5.6Note: QuickTest uses VBScript 5.6
VIBRANT TECHNOLOGIES & COMPUTERS
SCRIPTING FOR SPECIFIC PLATFORMS
VBScript
 designed to run on multiple platforms that use the ActiveX Scripting
Interface.
VBA (VB for Applications)
 More sophisticated customization.
 Power user focus, natural upgrade, superb integration
Visual Basic
 Best tool for distributed client/Server solutions.
 Powerful, robust, scalable.
5VIBRANT TECHNOLOGIES & COMPUTERS
VBSCRIPT DATA TYPES
VBScript has only one data type called a Variant.
A Variant is a special kind of data type that can contain
different kinds of information, depending on how it
is used.
Because Variant is the only data type in VBScript, it is
also the data type returned by all functions in
VBScript.
At its simplest, a Variant can contain either numeric or
string information.
A Variant behaves as a number when you use it in a
numeric context and as a string when you use it in a
string context.
6VIBRANT TECHNOLOGIES & COMPUTERS
VBSCRIPT DATA TYPES
VARIANT SUBTYPES
Beyond the simple numeric or string classifications, a
Variant can make further distinctions about the
specific nature of numeric information.
For example, you can have numeric information that
represents a date or a time.
When used with other date or time data, the result is
always expressed as a date or a time.
You can also have a rich variety of numeric information
ranging in size from Boolean values to huge floating-
point numbers.
7VIBRANT TECHNOLOGIES & COMPUTERS
VBSCRIPT DATA TYPES
VARIANT SUBTYPES
8
Subtype Description
Empty Variant is uninitialized. Value is 0 for numeric variables or a zero-length string ("") for string
variables.
Null Variant intentionally contains no valid data.
Boolean Contains either True or False.
Byte Contains integer in the range 0 to 255.
Integer Contains integer in the range -32,768 to 32,767.
Currency -922,337,203,685,477.5808 to 922,337,203,685,477.5807.
Long Contains integer in the range -2,147,483,648 to 2,147,483,647.
Single Contains a single-precision, floating-point number in the range -3.402823E38 to -1.401298E-45 for
negative values; 1.401298E-45 to 3.402823E38 for positive values.
Double Contains a double-precision, floating-point number in the range -1.79769313486232E308 to
-4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308
for positive values.
Date Contains a number that represents a date between January 1, 100 to December 31, 9999.
String Contains a variable-length string that can be up to approximately 2 billion characters in length.
Object Contains an object.
Error Contains an error number.
VIBRANT TECHNOLOGIES & COMPUTERS
VARIABLES
A variable is a convenient placeholder that refers to a
computer memory location where you can store
program information that may change during the
time your script is running.
For example, you might create a variable called
ClickCount to store the number of times a user clicks
an object on a particular Web page.
you only have to refer to a variable by his name to see
or change its value.
9VIBRANT TECHNOLOGIES & COMPUTERS
DECLARING VARIABLES
You declare variables explicitly in your script using the Dim
statement, the Public statement, and the Private
statement. For example:
Dim DegreesFahrenheit
You declare multiple variables by separating each variable
name with a comma. For example:
Dim Top, Bottom, Left, Right
10VIBRANT TECHNOLOGIES & COMPUTERS
DECLARING VARIABLES
You can also declare a variable implicitly by
simply using its name in your script.
That is not generally a good practice because
you could misspell the variable name in one
or more places, causing unexpected results
when your script is run.
For that reason, the Option Explicit statement is
available to require explicit declaration of all
variables.
11VIBRANT TECHNOLOGIES & COMPUTERS
OPTION EXPLICIT STATEMENT
Forces explicit declaration of all variables in a script.
If used, the Option Explicit statement must appear in a
script before any other statements.
When you use the Option Explicit statement, you must
explicitly declare all variables using the Dim, Private,
Public, or ReDim statements. If you attempt to use
an undeclared variable name, an error occurs.
Tip   Use Option Explicit to avoid incorrectly typing the
name of an existing variable or to avoid confusion in
code where the scope of the variable is not clear.
12VIBRANT TECHNOLOGIES & COMPUTERS
NAMING RESTRICTIONS
Must begin with an alphabetic character.
Cannot contain an embedded period.
Must not exceed 255 characters.
Must be unique in the scope in which it is
declared.
13
Tip   meaningfull prefix to variables to indicate
the subtypes i.e
iCounter (integer), strName (String), bFlag
(Boolean), dteToday (Date(
Tip   meaningfull prefix to variables to indicate
the subtypes i.e
iCounter (integer), strName (String), bFlag
(Boolean), dteToday (Date(
VIBRANT TECHNOLOGIES & COMPUTERS
VBSCRIPT KEYWORDS
Empty
 The Empty keyword is used to indicate an uninitialized variable value.
Null
 The Null keyword is used to indicate that a variable contains no valid data.
True
 The True keyword has a value equal to -1.
False
 The False keyword has a value equal to 0.
Nothing
 The Nothing keyword in VBScript is used to disassociate an object variable
from any actual object.
14VIBRANT TECHNOLOGIES & COMPUTERS
SCOPES AND LIFETIMES
A variable's scope is determined by where you declare it.
When you declare a variable within a procedure, only code within that
procedure can access or change the value of that variable.
If you declare a variable outside a procedure, you make it recognizable to all
the procedures in your script.
The lifetime of a variable depends on how long it exists.
The lifetime of a script-level variable extends from the time it is declared until
the time the script is finished running.
At procedure level, a variable exists only as long as you are in the procedure.
ou can have local variables of the same name in several different procedures
because each is recognized only by the procedure in which it is declared.
15VIBRANT TECHNOLOGIES & COMPUTERS
DIM STATEMENT
Dim varname[([subscripts])][, varname[([subscripts])]] . . .
Declares variables and allocates storage space.
Variables declared with Dim at the script level are available to all
procedures within the script.
At the procedure level, variables are available only within the
procedure.
You can also use the Dim statement with empty parentheses to
declare a dynamic array.
Note   When you use the Dim statement in a procedure, you
generally put the Dim statement at the beginning of the
procedure.
16VIBRANT TECHNOLOGIES & COMPUTERS
PRIVATE STATEMENT
Private varname[([subscripts])][, varname[([subscripts])]] . . .
Declares private variables and allocates storage space.
Private statement variables are available only to the script in which
they are declared.
The following example illustrates use of the Private statement:
17
Private MyNumber ‘--- Private Variant variable.
Private MyArray(9) ‘--- Private array variable.
‘--- Multiple Private declarations of Variant variables.
Private MyNumber, MyVar, YourNumber
VIBRANT TECHNOLOGIES & COMPUTERS
PUBLIC STATEMENT
Public varname[([subscripts])][, varname[([subscripts])]] . . .
Declares public variables and allocates storage space.
Public statement variables are available to all procedures in all
scripts.
You can also use the Public statement with empty parentheses
to declare a dynamic array.
18
Public MyNumber ‘--- Public Variant variable.
Public MyArray(9) ‘--- Public array variable.
‘--- Multiple Public declarations of Variant variables.
Public MyNumber, MyVar, YourNumber
Public MyNumber ‘--- Public Variant variable.
Public MyArray(9) ‘--- Public array variable.
‘--- Multiple Public declarations of Variant variables.
Public MyNumber, MyVar, YourNumber
VIBRANT TECHNOLOGIES & COMPUTERS
REM STATEMENT
Includes explanatory remarks in a program.
 Rem Comment
 ‘ Comment
As shown in the syntax section, you can use an apostrophe (') instead
of the Rem keyword.
If the Rem keyword follows other statements on a line, it must be
separated from the statements by a colon.
However, when you use an apostrophe, the colon is not required after
other statements.
19
MyStr1 = "Hello" : Rem Comment after a statement separated by a colon.
MyStr2 = "Goodbye" ' This is also a comment; no colon is needed.
Rem Comment on a line with no code; no colon is needed.
MyStr1 = "Hello" : Rem Comment after a statement separated by a colon.
MyStr2 = "Goodbye" ' This is also a comment; no colon is needed.
Rem Comment on a line with no code; no colon is needed.
VIBRANT TECHNOLOGIES & COMPUTERS
ASSIGNING VALUES TO VARIABLES
Values are assigned to variables creating an
expression as follows:
 the variable is on the left side of the expression and the value you want to
assign to the variable is on the right.
For Example :
20
B = 200B = 200
VIBRANT TECHNOLOGIES & COMPUTERS
LAB 1.1
21VIBRANT TECHNOLOGIES & COMPUTERS
LAB 1.1
Write a small program
 Declare using Dim 2 variables (a,b)
 Initialize the variables using a=“10” and b=“5”
 Apply the sum to variable c.
 Report to QTP the sum of the variables.
 Use remarks.
 TipTip : Conversion
Now declare in the header Option Explicit
22VIBRANT TECHNOLOGIES & COMPUTERS
VIBRANT TECHNOLOGIES & COMPUTERS 23

More Related Content

Similar to Qtp classes-in-mumbai

Vb script
Vb scriptVb script
Vb script
mcatahir947
 
Advanced+qtp+open+order
Advanced+qtp+open+orderAdvanced+qtp+open+order
Advanced+qtp+open+order
Ramu Palanki
 
VB Script Overview
VB Script OverviewVB Script Overview
VB Script Overview
Praveen Gorantla
 
Introduction to Visual Basic
Introduction to Visual Basic Introduction to Visual Basic
Advanced Qtp Book
Advanced Qtp BookAdvanced Qtp Book
Advanced Qtp Book
guestd9317c
 
VB PPT by ADI PART2.pdf
VB PPT by ADI PART2.pdfVB PPT by ADI PART2.pdf
VB PPT by ADI PART2.pdf
Prof. Dr. K. Adisesha
 
Advanced Qtp Book
Advanced Qtp BookAdvanced Qtp Book
Advanced Qtp Book
G.C Reddy
 
Vbs
VbsVbs
Qtp Scripts
Qtp ScriptsQtp Scripts
Qtp Scripts
G.C Reddy
 
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
 
Variables
VariablesVariables
Variables
Maha Saad
 
has any rows using Count(). This way, you avoid the CS8604 error related to p...
has any rows using Count(). This way, you avoid the CS8604 error related to p...has any rows using Count(). This way, you avoid the CS8604 error related to p...
has any rows using Count(). This way, you avoid the CS8604 error related to p...
Anwar Patel
 
ASP.Net Technologies Part-2
ASP.Net Technologies Part-2ASP.Net Technologies Part-2
ASP.Net Technologies Part-2
Vasudev Sharma
 
VB PPT by ADI PART2.pdf
VB PPT by ADI PART2.pdfVB PPT by ADI PART2.pdf
VB PPT by ADI PART2.pdf
AdiseshaK
 
E learning excel vba programming lesson 3
E learning excel vba programming  lesson 3E learning excel vba programming  lesson 3
E learning excel vba programming lesson 3
Vijay Perepa
 
7400354 vbscript-in-qtp
7400354 vbscript-in-qtp7400354 vbscript-in-qtp
7400354 vbscript-in-qtp
Bharath003
 
Refactoring legacy code driven by tests - ITA
Refactoring legacy code driven by tests -  ITARefactoring legacy code driven by tests -  ITA
Refactoring legacy code driven by tests - ITA
Luca Minudel
 
Typescript Basics
Typescript BasicsTypescript Basics
Typescript Basics
Manikandan [M M K]
 
1.2 programming fundamentals
1.2 programming fundamentals1.2 programming fundamentals
1.2 programming fundamentals
Jawad Khan
 

Similar to Qtp classes-in-mumbai (20)

Vb script
Vb scriptVb script
Vb script
 
Advanced+qtp+open+order
Advanced+qtp+open+orderAdvanced+qtp+open+order
Advanced+qtp+open+order
 
VB Script Overview
VB Script OverviewVB Script Overview
VB Script Overview
 
Introduction to Visual Basic
Introduction to Visual Basic Introduction to Visual Basic
Introduction to Visual Basic
 
Advanced Qtp Book
Advanced Qtp BookAdvanced Qtp Book
Advanced Qtp Book
 
VB PPT by ADI PART2.pdf
VB PPT by ADI PART2.pdfVB PPT by ADI PART2.pdf
VB PPT by ADI PART2.pdf
 
Advanced Qtp Book
Advanced Qtp BookAdvanced Qtp Book
Advanced Qtp Book
 
Vbs
VbsVbs
Vbs
 
Qtp Scripts
Qtp ScriptsQtp Scripts
Qtp Scripts
 
C programming session7
C programming  session7C programming  session7
C programming session7
 
C programming session7
C programming  session7C programming  session7
C programming session7
 
Variables
VariablesVariables
Variables
 
has any rows using Count(). This way, you avoid the CS8604 error related to p...
has any rows using Count(). This way, you avoid the CS8604 error related to p...has any rows using Count(). This way, you avoid the CS8604 error related to p...
has any rows using Count(). This way, you avoid the CS8604 error related to p...
 
ASP.Net Technologies Part-2
ASP.Net Technologies Part-2ASP.Net Technologies Part-2
ASP.Net Technologies Part-2
 
VB PPT by ADI PART2.pdf
VB PPT by ADI PART2.pdfVB PPT by ADI PART2.pdf
VB PPT by ADI PART2.pdf
 
E learning excel vba programming lesson 3
E learning excel vba programming  lesson 3E learning excel vba programming  lesson 3
E learning excel vba programming lesson 3
 
7400354 vbscript-in-qtp
7400354 vbscript-in-qtp7400354 vbscript-in-qtp
7400354 vbscript-in-qtp
 
Refactoring legacy code driven by tests - ITA
Refactoring legacy code driven by tests -  ITARefactoring legacy code driven by tests -  ITA
Refactoring legacy code driven by tests - ITA
 
Typescript Basics
Typescript BasicsTypescript Basics
Typescript Basics
 
1.2 programming fundamentals
1.2 programming fundamentals1.2 programming fundamentals
1.2 programming fundamentals
 

Recently uploaded

WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
Hiike
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Precisely
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
alexjohnson7307
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
marufrahmanstratejm
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 

Recently uploaded (20)

WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 

Qtp classes-in-mumbai

  • 2. Vbscript fundamentals. Variant subtypes. Variables. Option Explicit statement. Keywords. Scope and liftime of variables. Dim, Private and Public statements. Rem statement. 2VIBRANT TECHNOLOGIES & COMPUTERS
  • 3. WHAT IS VBSCRIPT? A Safe subset of visual basic The VBScript Code is case Insensitive. Microsoft Visual Basic Scripting Edition brings active scripting to a wide variety of environments, including Web client scripting in Microsoft Internet Explorer and Web server scripting in Microsoft Internet Information Service (IIS). 3VIBRANT TECHNOLOGIES & COMPUTERS
  • 4. MICROSOFT® SCRIPT TIMELINE 4 Internet Explorer 3.0 8/96 Version 1.0 Version 2.0 IIS 2 12/96 Internet Explorer 4.0 8/97 Version 3.0 Windows 98 Version 3.1 Version 4.0 Version 5.0 Visual Studio 6 Internet Explorer 5.0 Win NT 5.0 Note: QuickTest uses VBScript 5.6Note: QuickTest uses VBScript 5.6 VIBRANT TECHNOLOGIES & COMPUTERS
  • 5. SCRIPTING FOR SPECIFIC PLATFORMS VBScript  designed to run on multiple platforms that use the ActiveX Scripting Interface. VBA (VB for Applications)  More sophisticated customization.  Power user focus, natural upgrade, superb integration Visual Basic  Best tool for distributed client/Server solutions.  Powerful, robust, scalable. 5VIBRANT TECHNOLOGIES & COMPUTERS
  • 6. VBSCRIPT DATA TYPES VBScript has only one data type called a Variant. A Variant is a special kind of data type that can contain different kinds of information, depending on how it is used. Because Variant is the only data type in VBScript, it is also the data type returned by all functions in VBScript. At its simplest, a Variant can contain either numeric or string information. A Variant behaves as a number when you use it in a numeric context and as a string when you use it in a string context. 6VIBRANT TECHNOLOGIES & COMPUTERS
  • 7. VBSCRIPT DATA TYPES VARIANT SUBTYPES Beyond the simple numeric or string classifications, a Variant can make further distinctions about the specific nature of numeric information. For example, you can have numeric information that represents a date or a time. When used with other date or time data, the result is always expressed as a date or a time. You can also have a rich variety of numeric information ranging in size from Boolean values to huge floating- point numbers. 7VIBRANT TECHNOLOGIES & COMPUTERS
  • 8. VBSCRIPT DATA TYPES VARIANT SUBTYPES 8 Subtype Description Empty Variant is uninitialized. Value is 0 for numeric variables or a zero-length string ("") for string variables. Null Variant intentionally contains no valid data. Boolean Contains either True or False. Byte Contains integer in the range 0 to 255. Integer Contains integer in the range -32,768 to 32,767. Currency -922,337,203,685,477.5808 to 922,337,203,685,477.5807. Long Contains integer in the range -2,147,483,648 to 2,147,483,647. Single Contains a single-precision, floating-point number in the range -3.402823E38 to -1.401298E-45 for negative values; 1.401298E-45 to 3.402823E38 for positive values. Double Contains a double-precision, floating-point number in the range -1.79769313486232E308 to -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values. Date Contains a number that represents a date between January 1, 100 to December 31, 9999. String Contains a variable-length string that can be up to approximately 2 billion characters in length. Object Contains an object. Error Contains an error number. VIBRANT TECHNOLOGIES & COMPUTERS
  • 9. VARIABLES A variable is a convenient placeholder that refers to a computer memory location where you can store program information that may change during the time your script is running. For example, you might create a variable called ClickCount to store the number of times a user clicks an object on a particular Web page. you only have to refer to a variable by his name to see or change its value. 9VIBRANT TECHNOLOGIES & COMPUTERS
  • 10. DECLARING VARIABLES You declare variables explicitly in your script using the Dim statement, the Public statement, and the Private statement. For example: Dim DegreesFahrenheit You declare multiple variables by separating each variable name with a comma. For example: Dim Top, Bottom, Left, Right 10VIBRANT TECHNOLOGIES & COMPUTERS
  • 11. DECLARING VARIABLES You can also declare a variable implicitly by simply using its name in your script. That is not generally a good practice because you could misspell the variable name in one or more places, causing unexpected results when your script is run. For that reason, the Option Explicit statement is available to require explicit declaration of all variables. 11VIBRANT TECHNOLOGIES & COMPUTERS
  • 12. OPTION EXPLICIT STATEMENT Forces explicit declaration of all variables in a script. If used, the Option Explicit statement must appear in a script before any other statements. When you use the Option Explicit statement, you must explicitly declare all variables using the Dim, Private, Public, or ReDim statements. If you attempt to use an undeclared variable name, an error occurs. Tip   Use Option Explicit to avoid incorrectly typing the name of an existing variable or to avoid confusion in code where the scope of the variable is not clear. 12VIBRANT TECHNOLOGIES & COMPUTERS
  • 13. NAMING RESTRICTIONS Must begin with an alphabetic character. Cannot contain an embedded period. Must not exceed 255 characters. Must be unique in the scope in which it is declared. 13 Tip   meaningfull prefix to variables to indicate the subtypes i.e iCounter (integer), strName (String), bFlag (Boolean), dteToday (Date( Tip   meaningfull prefix to variables to indicate the subtypes i.e iCounter (integer), strName (String), bFlag (Boolean), dteToday (Date( VIBRANT TECHNOLOGIES & COMPUTERS
  • 14. VBSCRIPT KEYWORDS Empty  The Empty keyword is used to indicate an uninitialized variable value. Null  The Null keyword is used to indicate that a variable contains no valid data. True  The True keyword has a value equal to -1. False  The False keyword has a value equal to 0. Nothing  The Nothing keyword in VBScript is used to disassociate an object variable from any actual object. 14VIBRANT TECHNOLOGIES & COMPUTERS
  • 15. SCOPES AND LIFETIMES A variable's scope is determined by where you declare it. When you declare a variable within a procedure, only code within that procedure can access or change the value of that variable. If you declare a variable outside a procedure, you make it recognizable to all the procedures in your script. The lifetime of a variable depends on how long it exists. The lifetime of a script-level variable extends from the time it is declared until the time the script is finished running. At procedure level, a variable exists only as long as you are in the procedure. ou can have local variables of the same name in several different procedures because each is recognized only by the procedure in which it is declared. 15VIBRANT TECHNOLOGIES & COMPUTERS
  • 16. DIM STATEMENT Dim varname[([subscripts])][, varname[([subscripts])]] . . . Declares variables and allocates storage space. Variables declared with Dim at the script level are available to all procedures within the script. At the procedure level, variables are available only within the procedure. You can also use the Dim statement with empty parentheses to declare a dynamic array. Note   When you use the Dim statement in a procedure, you generally put the Dim statement at the beginning of the procedure. 16VIBRANT TECHNOLOGIES & COMPUTERS
  • 17. PRIVATE STATEMENT Private varname[([subscripts])][, varname[([subscripts])]] . . . Declares private variables and allocates storage space. Private statement variables are available only to the script in which they are declared. The following example illustrates use of the Private statement: 17 Private MyNumber ‘--- Private Variant variable. Private MyArray(9) ‘--- Private array variable. ‘--- Multiple Private declarations of Variant variables. Private MyNumber, MyVar, YourNumber VIBRANT TECHNOLOGIES & COMPUTERS
  • 18. PUBLIC STATEMENT Public varname[([subscripts])][, varname[([subscripts])]] . . . Declares public variables and allocates storage space. Public statement variables are available to all procedures in all scripts. You can also use the Public statement with empty parentheses to declare a dynamic array. 18 Public MyNumber ‘--- Public Variant variable. Public MyArray(9) ‘--- Public array variable. ‘--- Multiple Public declarations of Variant variables. Public MyNumber, MyVar, YourNumber Public MyNumber ‘--- Public Variant variable. Public MyArray(9) ‘--- Public array variable. ‘--- Multiple Public declarations of Variant variables. Public MyNumber, MyVar, YourNumber VIBRANT TECHNOLOGIES & COMPUTERS
  • 19. REM STATEMENT Includes explanatory remarks in a program.  Rem Comment  ‘ Comment As shown in the syntax section, you can use an apostrophe (') instead of the Rem keyword. If the Rem keyword follows other statements on a line, it must be separated from the statements by a colon. However, when you use an apostrophe, the colon is not required after other statements. 19 MyStr1 = "Hello" : Rem Comment after a statement separated by a colon. MyStr2 = "Goodbye" ' This is also a comment; no colon is needed. Rem Comment on a line with no code; no colon is needed. MyStr1 = "Hello" : Rem Comment after a statement separated by a colon. MyStr2 = "Goodbye" ' This is also a comment; no colon is needed. Rem Comment on a line with no code; no colon is needed. VIBRANT TECHNOLOGIES & COMPUTERS
  • 20. ASSIGNING VALUES TO VARIABLES Values are assigned to variables creating an expression as follows:  the variable is on the left side of the expression and the value you want to assign to the variable is on the right. For Example : 20 B = 200B = 200 VIBRANT TECHNOLOGIES & COMPUTERS
  • 22. LAB 1.1 Write a small program  Declare using Dim 2 variables (a,b)  Initialize the variables using a=“10” and b=“5”  Apply the sum to variable c.  Report to QTP the sum of the variables.  Use remarks.  TipTip : Conversion Now declare in the header Option Explicit 22VIBRANT TECHNOLOGIES & COMPUTERS
  • 23. VIBRANT TECHNOLOGIES & COMPUTERS 23