SlideShare a Scribd company logo
1 of 7
VBScript in QTP 
Microsoft VBScript (Visual Basic Script) is a general-purpose, lightweight , scripting language developed 
by Microsoft which is modeled on Visual Basic. VBScript is the main scripting language for Quick Test 
Professional (QTP). 
As Vb Script is Lightweight language, there is no need to compile the program, during execution they 
got interpreted and run. No .exe file got generated. 
Script engines like Wscript.exe & Cscript.exe interpret VBScript file in Windows GUI environment 
using Windows script Host. WSH is the system module that transforms a VBScript file into a Windows 
executable file. Wscript.exe is used to display output and receive input in Windows GUI format such as 
dialog and input boxes. Cscript.exe is used in a command-line environment. 
VBScript Variable 
In VBScript all variables are of the type variant that can store any type of value. 
It supports int, long, double, String, Boolean ,date datatypes. A variant behaves as a number when it is 
used in a numeric context and as a string when used in a string context. 
Variables can be declared using the following statements that determines the scope of the variable. 
The scope of the variable plays a crucial role when used within a procedure or classes. 
ñDim --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. 
ñPublic Variables declared using "Public" Keyword are available to all the procedures across all the 
associated scripts. 
ñPrivate --Variables that are declared as "Private" have scope only within that script in which they are 
declared. 
VB Script String Functions: 
Len Function : Returns the number of characters in a string 
Example: 
Str="Welcome to the QTP Learning Blog" 
Msgbox Len(Str) 
' Output --> 32 
Msgbox Len("Mindfire Solutions") 
' Output--> 18
LCase Function : Returns a string that has been converted to lowercase. 
Example: 
Str="Welcome to the QTP Learning Blog" 
Msgbox LCase(Str) 
' Output --> welcome to the qtp learning blog 
Msgbox LCase("Mindfire Solutions") 
' Output--> mindfire solutions 
UCase Function : Returns a string that has been converted to uppercase. 
Str="Welcome to the QTP Learning Blog" 
Msgbox UCase(Str) 
' Output --> WELCOME TO QTP LEARNING BLOG 
Msgbox UCase("Mindfire Solutions") 
' Output--> MINDFIRE SOLUTIONS 
Left Function :Returns a specified number of characters from the left side of a string. 
Str="Welcome to the QTP Learning Blog" 
Msgbox LEFT(Str,7) 
' Output --> Welcome 
Msgbox LEFT("Mindfire Solutions",2) 
' Output--> Mi 
second parameter is Numeric expression indicating how many characters to return. If 0, a zero-length 
string("") is returned. If greater than or equal to the number of characters in string, the entire string is 
returned. 
Msgbox LEFT(Str,40) 
' Output --> WELCOME TO QTP LEARNING BLOG
Msgbox LEFT("Mindfire Solutions",0) O/P—blank msgbox 
Right Function : Returns a specified number of characters from the right side of a string. 
Str="Welcome to the QTP Learning Blog" 
Msgbox Right(Str,7) 
' Output --> ng Blog 
Msgbox Right("Mindfire Solutions",2) 
' Output--> ns 
second parameter is Numeric expression indicating how many characters to return. If 0, a zero-length 
string("") is returned. If greater than or equal to the number of characters in string, the entire string is 
returned. 
Msgbox Right(Str,40) 
' Output --> WELCOME TO QTP LEARNING BLOG 
Msgbox Right("Mindfire Solutions",0) O/P—blank msgbox 
Mid Function : Returns a specified number of characters from a string. 
Str="Welcome to the QTP Learning Blog" 
Msgbox Mid(Str,3,4) 
' Output --> lcom 
Msgbox Mid("Mindfire Solutions",2,5) 
' Output--> indfi 
Msgbox Mid("Mindfire Solutions",2) 
' Output--> indfire Solutions 
Second parameter, in string at which the part to be taken begins. If start is greater than the number 
of characters in string, Mid returns a zero-length string ("") which is blank. 
Third parameter, Number of characters to return. If omitted , all characters from the start position to 
the end of the string are returned. 
Replace Function : It Returns a string in which a specified substring has been replaced with another
substring a specified number of times. 
Str="Welcome to the QTP Learning Blog" 
print Replace(Str, "to","into") 
'Output --> Welcome into the QTP Learning Blog 
Print Replace("Mindfire Solutions","Solutions","Org") 
'Output --> Mindfire Org 
Print Replace("Quick Test ProfeSsional","s","x",5,3,0) 
'Output --> k Text ProfeSxional 
Print Replace("Quick Test ProfeSsional","s","x",5,3,1) 
'Output --> k Text Profexxional 
Second parameter, in string is which specified substring has been replaced 
Third parameter, is the Replacement substring. 
Fourth, Fifth and Sixth parameters are optional. Fourth and fifth stands for start position and count. 
Both are used in together. Sixth is compare mode, default is 0 (binary comparison) which means case 
sensitive. If 1, then case in sensitive. 
Space Function : It Returns a string consisting of the specified number of spaces. 
Str1="Welcome" 
Str2="to the QTP" 
Str3="Learning Blog" 
Str4="By Nilanjan" 
MsgBox Str1 & Space(10) & Str2 & Space(2) &Str3 &Str4 
'Output--> Welcome to the QTP Learning BlogBy Nilanjan 
Split Function : it Returns an one-dimensional array containing a specified number of substrings. 
'Comma As Delimitter 
Str="Welcome,to,the,QTP, Learning,Blog" 
'Split
SArray=Split(Str,",",-1) 
For i= 0 to UBound(SArray) 
Msgbox SArray(i) 
Next 
SArray here holds the returned array 
StrComp Function : It Returns a value indicating the result of a string comparison. 
Str="Welcome into the QTP Learning Blog" 
Str1 = "QTP" 
Str2 = "qtp" 
Msgbox StrComp(Str1, Str2, 1) 
'Output--> Returns 0 , which means Str1 is equal to Str2 for textual comparison 
Msgbox StrComp(Str1, Str2, 0) 
'Output--> Returns -1 , which means Str2 is greater than Str1 for Binary comparison 
Msgbox StrComp("Nilanjana", "Nilanjan", 0) 
'Output--> Returns 1 
StrReverse Function : It Returns a string in which the character order of a specified string is reversed. 
Str="Welcome to the QTP Learning Blog” 
msgbox StrReverse(Str) 
'Output-->gplB gninraeL PTQ eht ot emocleW 
Msgbox StrReverse("Mindfire Solutions") 
'Output-->snoituloS erifdniM 
Trim Functions : t Returns a copy of a string without leading and trailing spaces 
LTrim : It Returns a copy of a string without leading spaces 
Rtrim: It Returns a copy of a string without trailing spaces 
Example:
'LTrim 
Msgbox Ltrim(" Welcome to the QTP Learning Blog ") 
'Output-->"Welcome to the QTP Learning Blog “ 
Example: 
'RTrim 
Msgbox Rtrim(" Welcome to the QTP Learning Blog ") 
'Output--> " Welcome to the QTP Learning Blog " 
Example: 
'Trim 
Msgbox Trim(" Welcome to the QTP Learning Blog ") 
'Output-->"Welcome to the QTP Learning Blog " 
InStr Function : It Returns the position of the first occurrence of one string within another string. 
Str="Welcome to the QTP Learning Blog.qtp is a testing tool" 
msgbox Instr(1, Str, "QTP", 1) 
'Output--> 16 , which means it found the string in 16th position for textual comparison 
msgbox Instr(6, Str, "qtp", 0) 
'Output--> 34 , which means it found the string in 34th position for binary comparison. 
Search started from 6th character. 
msgbox Instr(6, Str, "Ftp", 0) 
'Output--> 0 , which means it did not found the string after the 6th position 
for binary comparison
Learn VbScript -String Functions

More Related Content

What's hot

Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoft
ch samaram
 
Advanced+qtp+open+order
Advanced+qtp+open+orderAdvanced+qtp+open+order
Advanced+qtp+open+order
Ramu Palanki
 

What's hot (20)

7400354 vbscript-in-qtp
7400354 vbscript-in-qtp7400354 vbscript-in-qtp
7400354 vbscript-in-qtp
 
Vb script
Vb scriptVb script
Vb script
 
Vbs
VbsVbs
Vbs
 
Operators used in vb.net
Operators used in vb.netOperators used in vb.net
Operators used in vb.net
 
Conditional statements in vb script
Conditional statements in vb scriptConditional statements in vb script
Conditional statements in vb script
 
TypeScript, Now.
TypeScript, Now.TypeScript, Now.
TypeScript, Now.
 
Vb script final pari
Vb script final pariVb script final pari
Vb script final pari
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoft
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
 
Javascript conditional statements
Javascript conditional statementsJavascript conditional statements
Javascript conditional statements
 
Vb script tutorial
Vb script tutorialVb script tutorial
Vb script tutorial
 
Looping statements
Looping statementsLooping statements
Looping statements
 
JavaScript Conditional Statements
JavaScript Conditional StatementsJavaScript Conditional Statements
JavaScript Conditional Statements
 
CONST-- once initialised, no one can change it
CONST-- once initialised, no one can change itCONST-- once initialised, no one can change it
CONST-- once initialised, no one can change it
 
Javascripts hidden treasures BY - https://geekyants.com/
Javascripts hidden treasures            BY  -  https://geekyants.com/Javascripts hidden treasures            BY  -  https://geekyants.com/
Javascripts hidden treasures BY - https://geekyants.com/
 
Spf Chapter5 Conditional Logics
Spf Chapter5 Conditional LogicsSpf Chapter5 Conditional Logics
Spf Chapter5 Conditional Logics
 
C# Loops
C# LoopsC# Loops
C# Loops
 
Spf Chapter4 Variables
Spf Chapter4 VariablesSpf Chapter4 Variables
Spf Chapter4 Variables
 
Switch case and looping jam
Switch case and looping jamSwitch case and looping jam
Switch case and looping jam
 
Advanced+qtp+open+order
Advanced+qtp+open+orderAdvanced+qtp+open+order
Advanced+qtp+open+order
 

Viewers also liked (7)

Qtp vb scripting
Qtp vb scriptingQtp vb scripting
Qtp vb scripting
 
Vb script reference
Vb script referenceVb script reference
Vb script reference
 
vbscripting
vbscriptingvbscripting
vbscripting
 
VBScript Tutorial
VBScript TutorialVBScript Tutorial
VBScript Tutorial
 
vb script
vb scriptvb script
vb script
 
Intorudction into VBScript
Intorudction into VBScriptIntorudction into VBScript
Intorudction into VBScript
 
VBscript
VBscriptVBscript
VBscript
 

Similar to Learn VbScript -String Functions

Similar to Learn VbScript -String Functions (20)

stringsinpython-181122100212.pdf
stringsinpython-181122100212.pdfstringsinpython-181122100212.pdf
stringsinpython-181122100212.pdf
 
Strings in python
Strings in pythonStrings in python
Strings in python
 
Functions.docx
Functions.docxFunctions.docx
Functions.docx
 
13. Java text processing
13.  Java text processing13.  Java text processing
13. Java text processing
 
Best C++ Programming Homework Help
Best C++ Programming Homework HelpBest C++ Programming Homework Help
Best C++ Programming Homework Help
 
Python Strings Methods
Python Strings MethodsPython Strings Methods
Python Strings Methods
 
Python Training in Bangalore | Python Introduction Session | Learnbay
Python Training in Bangalore |  Python Introduction Session | LearnbayPython Training in Bangalore |  Python Introduction Session | Learnbay
Python Training in Bangalore | Python Introduction Session | Learnbay
 
Javascript
JavascriptJavascript
Javascript
 
Runtime Bytecode Transformation for Smalltalk
Runtime Bytecode Transformation for SmalltalkRuntime Bytecode Transformation for Smalltalk
Runtime Bytecode Transformation for Smalltalk
 
The Ring programming language version 1.3 book - Part 26 of 88
The Ring programming language version 1.3 book - Part 26 of 88The Ring programming language version 1.3 book - Part 26 of 88
The Ring programming language version 1.3 book - Part 26 of 88
 
Implementation of 'go-like' language constructions in scala [english version]
Implementation of 'go-like' language constructions in scala [english version] Implementation of 'go-like' language constructions in scala [english version]
Implementation of 'go-like' language constructions in scala [english version]
 
Runtime Bytecode Transformation for Smalltalk
Runtime Bytecode Transformation for SmalltalkRuntime Bytecode Transformation for Smalltalk
Runtime Bytecode Transformation for Smalltalk
 
Advanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter pptAdvanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter ppt
 
strings11.pdf
strings11.pdfstrings11.pdf
strings11.pdf
 
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
 
13 Strings and Text Processing
13 Strings and Text Processing13 Strings and Text Processing
13 Strings and Text Processing
 
Variables
VariablesVariables
Variables
 
Matlab-3.pptx
Matlab-3.pptxMatlab-3.pptx
Matlab-3.pptx
 
Advanced Web Technology ass.pdf
Advanced Web Technology ass.pdfAdvanced Web Technology ass.pdf
Advanced Web Technology ass.pdf
 
Python basics
Python basicsPython basics
Python basics
 

Recently uploaded

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
ssuserdda66b
 

Recently uploaded (20)

Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 

Learn VbScript -String Functions

  • 1. VBScript in QTP Microsoft VBScript (Visual Basic Script) is a general-purpose, lightweight , scripting language developed by Microsoft which is modeled on Visual Basic. VBScript is the main scripting language for Quick Test Professional (QTP). As Vb Script is Lightweight language, there is no need to compile the program, during execution they got interpreted and run. No .exe file got generated. Script engines like Wscript.exe & Cscript.exe interpret VBScript file in Windows GUI environment using Windows script Host. WSH is the system module that transforms a VBScript file into a Windows executable file. Wscript.exe is used to display output and receive input in Windows GUI format such as dialog and input boxes. Cscript.exe is used in a command-line environment. VBScript Variable In VBScript all variables are of the type variant that can store any type of value. It supports int, long, double, String, Boolean ,date datatypes. A variant behaves as a number when it is used in a numeric context and as a string when used in a string context. Variables can be declared using the following statements that determines the scope of the variable. The scope of the variable plays a crucial role when used within a procedure or classes. ñDim --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. ñPublic Variables declared using "Public" Keyword are available to all the procedures across all the associated scripts. ñPrivate --Variables that are declared as "Private" have scope only within that script in which they are declared. VB Script String Functions: Len Function : Returns the number of characters in a string Example: Str="Welcome to the QTP Learning Blog" Msgbox Len(Str) ' Output --> 32 Msgbox Len("Mindfire Solutions") ' Output--> 18
  • 2. LCase Function : Returns a string that has been converted to lowercase. Example: Str="Welcome to the QTP Learning Blog" Msgbox LCase(Str) ' Output --> welcome to the qtp learning blog Msgbox LCase("Mindfire Solutions") ' Output--> mindfire solutions UCase Function : Returns a string that has been converted to uppercase. Str="Welcome to the QTP Learning Blog" Msgbox UCase(Str) ' Output --> WELCOME TO QTP LEARNING BLOG Msgbox UCase("Mindfire Solutions") ' Output--> MINDFIRE SOLUTIONS Left Function :Returns a specified number of characters from the left side of a string. Str="Welcome to the QTP Learning Blog" Msgbox LEFT(Str,7) ' Output --> Welcome Msgbox LEFT("Mindfire Solutions",2) ' Output--> Mi second parameter is Numeric expression indicating how many characters to return. If 0, a zero-length string("") is returned. If greater than or equal to the number of characters in string, the entire string is returned. Msgbox LEFT(Str,40) ' Output --> WELCOME TO QTP LEARNING BLOG
  • 3. Msgbox LEFT("Mindfire Solutions",0) O/P—blank msgbox Right Function : Returns a specified number of characters from the right side of a string. Str="Welcome to the QTP Learning Blog" Msgbox Right(Str,7) ' Output --> ng Blog Msgbox Right("Mindfire Solutions",2) ' Output--> ns second parameter is Numeric expression indicating how many characters to return. If 0, a zero-length string("") is returned. If greater than or equal to the number of characters in string, the entire string is returned. Msgbox Right(Str,40) ' Output --> WELCOME TO QTP LEARNING BLOG Msgbox Right("Mindfire Solutions",0) O/P—blank msgbox Mid Function : Returns a specified number of characters from a string. Str="Welcome to the QTP Learning Blog" Msgbox Mid(Str,3,4) ' Output --> lcom Msgbox Mid("Mindfire Solutions",2,5) ' Output--> indfi Msgbox Mid("Mindfire Solutions",2) ' Output--> indfire Solutions Second parameter, in string at which the part to be taken begins. If start is greater than the number of characters in string, Mid returns a zero-length string ("") which is blank. Third parameter, Number of characters to return. If omitted , all characters from the start position to the end of the string are returned. Replace Function : It Returns a string in which a specified substring has been replaced with another
  • 4. substring a specified number of times. Str="Welcome to the QTP Learning Blog" print Replace(Str, "to","into") 'Output --> Welcome into the QTP Learning Blog Print Replace("Mindfire Solutions","Solutions","Org") 'Output --> Mindfire Org Print Replace("Quick Test ProfeSsional","s","x",5,3,0) 'Output --> k Text ProfeSxional Print Replace("Quick Test ProfeSsional","s","x",5,3,1) 'Output --> k Text Profexxional Second parameter, in string is which specified substring has been replaced Third parameter, is the Replacement substring. Fourth, Fifth and Sixth parameters are optional. Fourth and fifth stands for start position and count. Both are used in together. Sixth is compare mode, default is 0 (binary comparison) which means case sensitive. If 1, then case in sensitive. Space Function : It Returns a string consisting of the specified number of spaces. Str1="Welcome" Str2="to the QTP" Str3="Learning Blog" Str4="By Nilanjan" MsgBox Str1 & Space(10) & Str2 & Space(2) &Str3 &Str4 'Output--> Welcome to the QTP Learning BlogBy Nilanjan Split Function : it Returns an one-dimensional array containing a specified number of substrings. 'Comma As Delimitter Str="Welcome,to,the,QTP, Learning,Blog" 'Split
  • 5. SArray=Split(Str,",",-1) For i= 0 to UBound(SArray) Msgbox SArray(i) Next SArray here holds the returned array StrComp Function : It Returns a value indicating the result of a string comparison. Str="Welcome into the QTP Learning Blog" Str1 = "QTP" Str2 = "qtp" Msgbox StrComp(Str1, Str2, 1) 'Output--> Returns 0 , which means Str1 is equal to Str2 for textual comparison Msgbox StrComp(Str1, Str2, 0) 'Output--> Returns -1 , which means Str2 is greater than Str1 for Binary comparison Msgbox StrComp("Nilanjana", "Nilanjan", 0) 'Output--> Returns 1 StrReverse Function : It Returns a string in which the character order of a specified string is reversed. Str="Welcome to the QTP Learning Blog” msgbox StrReverse(Str) 'Output-->gplB gninraeL PTQ eht ot emocleW Msgbox StrReverse("Mindfire Solutions") 'Output-->snoituloS erifdniM Trim Functions : t Returns a copy of a string without leading and trailing spaces LTrim : It Returns a copy of a string without leading spaces Rtrim: It Returns a copy of a string without trailing spaces Example:
  • 6. 'LTrim Msgbox Ltrim(" Welcome to the QTP Learning Blog ") 'Output-->"Welcome to the QTP Learning Blog “ Example: 'RTrim Msgbox Rtrim(" Welcome to the QTP Learning Blog ") 'Output--> " Welcome to the QTP Learning Blog " Example: 'Trim Msgbox Trim(" Welcome to the QTP Learning Blog ") 'Output-->"Welcome to the QTP Learning Blog " InStr Function : It Returns the position of the first occurrence of one string within another string. Str="Welcome to the QTP Learning Blog.qtp is a testing tool" msgbox Instr(1, Str, "QTP", 1) 'Output--> 16 , which means it found the string in 16th position for textual comparison msgbox Instr(6, Str, "qtp", 0) 'Output--> 34 , which means it found the string in 34th position for binary comparison. Search started from 6th character. msgbox Instr(6, Str, "Ftp", 0) 'Output--> 0 , which means it did not found the string after the 6th position for binary comparison