Escolar Documentos
Profissional Documentos
Cultura Documentos
cid=36
VB Script - Part III Len : Returns the number of characters in a string or the number of bytes required to store a variable.
Excel Arguments:
Actions
string: Any valid string expression. If string contains Null, Null is returned.
Functions
varname: Any valid variable name. If varname contains Null, Null is returned.
Difference between Action and
Function
Example:
Parameterization
Str="Welcome to the World of QTP"
Object Repository Print Len(Str)
' Output --> 27
Descriptive Programming
Print Len("Good Morning")
Regular Expression ' Output--> 12
Output Values LCase: Returns a string that has been converted to lowercase.
Synchronization
String: Any valid string expression. If string contains Null, Null is returned.
Environment Variables
XML
Example:
Outlook Str="Welcome to the World of QTP"
Reporting Defect Print LCase(Str)
'Output --> welcome to the world of qtp
UCase Function
info@qtpworld.com
Ucase : Returns a string that has been converted to uppercase.
+91- 9886477710
Syntax: UCase(string)
Arguments:
String: Any valid string expression. If string contains Null, Null is returned.
Example:
Print Ucase(Str)
'Output --> WELCOME TO THE WORLD OF QTP
Left Function
Left: Returns a specified number of characters from the left side of a string.
Arguments:
String: String expression from which the leftmost characters are returned. If string contains Null, Null is returned.
1 of 5 1/29/2016 3:19 AM
QTPWorld http://www.qtpworld.com/index.php?cid=36
Numeric expression indicating how many characters to return. If 0, a zero-length string("") is returned. If greater than
length:
or equal to the number of characters in string, the entire string is returned.
Example:
print Left(Str,3)
'Output --> Wel
Right Function
Right: Returns a specified number of characters from the right side of a string.
Arguments:
String: String expression from which the rightmost characters are returned. If string contains Null, Null is returned.
Numeric expression indicating how many characters to return. If 0, a zero-length string is returned. If greater than or equal
length:
to the number of characters in string, the entire string is returned.
Example:
print Right(Str,12)
'Output --> World of QTP
Mid Function
Aruguments:
String: String expression from which characters are returned. If string contains Null, Null is returned.
Character position in string at which the part to be taken begins. If start is greater than the number of characters in string, Mid
Start:
returns a zero-length string ("").
Number of characters to return. If omitted or if there are fewer than length characters in the text (including the character
length:
at start), all characters from the start position to the end of the string are returned.
Example:
print Mid(Str,9,12)
'Output --> to the World
Replace Function
Replace: Returns a string in which a specified substring has been replaced with another substring a specified number of times.
Arguments:
(Optional) Number of substring substitutions to perform. If omitted, the default value is -1, which means make all
count: possible substitutions. Must be used in conjunction with start.
(Optional) Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for
compare: values. If omitted, the default value is 0, which means perform a binary comparison.
2 of 5 1/29/2016 3:19 AM
QTPWorld http://www.qtpworld.com/index.php?cid=36
Example:
Space Function
Syntax: Space(number)
Arguments:
Example:
'Space
Str1="Welcome"
Str2="to the World"
Str3="of QTP"
Split Function
Arguments:
(Required) String expression containing substrings and delimiters. If expression is a zero-length string, Split returns
expression:
an empty array, that is, an array with no elements and no data.
(Optional) String character used to identify substring limits. If omitted, the space character (" ") is assumed to be the
delimiter:
delimiter. If delimiter is a zero-length string, a single-element array containing the entire expression string is returned.
count: (Optional) Number of substrings to be returned; -1 indicates that all substrings are returned.
compare: (Optional) Numeric value indicating the kind of comparison to use when evaluating substrings.
Example:
'Space as Delimiter
Str="Welcome to the World of QTP"
'Split
SArray=Split(Str," ",-1)
For i= 0 to UBound(SArray)
Print SArray(i)
Next
'Comma As Delimitter
Str="Welcome,to,the,World,of,QTP"
'Split
SArray=Split(Str,",",-1)
For i= 0 to UBound(SArray)
Print SArray(i)
Next
StrComp Function
3 of 5 1/29/2016 3:19 AM
QTPWorld http://www.qtpworld.com/index.php?cid=36
Arguments:
Example:
StrComp
Str1 = "QTP"
Str2 = "qtp"
StrReverse Function
StrReverse: Returns a string in which the character order of a specified string is reversed.
Syntax: StrReverse(string1)
Arguments:
Example:
StrReverse
print StrReverse(Str)
'Output-->PTQ fo dlroW eht ot emocleW
LTrim; RTrim; and Trim: Returns a copy of a string without leading spaces (LTrim), trailing spaces (RTrim), or both leading
and trailing spaces (Trim).
Syntax: LTrim(string)
RTrim(string)
Trim(string)
Arguments:
string: The string argument is any valid string expression. If string contains Null, Null is returned.
Example:
'LTrim
'Output-->"Welcome to QTPWorld.com
Example:
'RTrim
Example:
'Trim
InStr Function
InStr: Returns the position of the first occurrence of one string within another.
Arguments:
start: (Optional) Numeric expression that sets the starting position for each search. If omitted, search begins at the first
4 of 5 1/29/2016 3:19 AM
QTPWorld http://www.qtpworld.com/index.php?cid=36
character position. If start contains Null, an error occurs. The start argument is required if compare is specified.
(Optional) Numeric value indicating the kind of comparison to use when evaluating substrings.
compare:
Example:
'InStr
InStrRev Function
InStrRev: Returns the position of an occurrence of one string within another, from the end of string.
Arguments:
(Optional) Numeric value indicating the kind of comparison to use when evaluating substrings. If omitted, a binary
compare: comparison is performed.
Example:
'InStrRev
Print InStrRev(Str,"DO",-1,1)
'Output--> 12 , which means it found the string in 12th position for textual comparison
Print InStrRev(Str,"do",-1,0)
'Output--> 5 , which means it found the string in 5th position for binary comparison
Print InStrRev(Str,"DO",13,0)
'Output--> 12 , which means it found the string in 12th position for binary comparison
Print InStrRev(Str,"DO",10,1)
'Output--> 5 , which means it found the string in 5th position for textual comparison
Copyright QTPWorld.com 2013 Home | Demo videos | Students | Training | FAQ's | Feedback | About Us Designed By WebZone
5 of 5 1/29/2016 3:19 AM