1) Instr function in QTP
Instr returns first occurance of the string1 with in another string2.
Syntex:
Instr([start,] String1,String2, [compare])
Here,
Start = optional, Postion of the start search from String1
String1 = Required, This is main String.
String2 = Required, This is sub String to be search in String2
Compare = Optional, Specifies the string comparison to use. Default is 0
Can have one of the following values:
0 = vbBinaryCompare - Perform a binary comparison
1 = vbTextCompare - Perform a textual comparison
Return Values :
0 -> If String1 is ""
0 -> If String2 is not found
0 -> if start > len(String1)
Null -> If String1 is Null
Null -> If String2 is Null
Start val -> If Strin2 is ""
position val-> If string2 is found within string1
Example :
Instr(1,"The QTP Tutorial","T")
o/p 1
2) InStrRev function in QTP
InstrRev returns first occurance of the String1 with in another string. The search begin starts from end of the string. But position returned counts from the beginning of the string.
Syntex:
InStrRev(String1,String2[,start],[compare])
Here,
String1 = Required, This is main String.
String2 = Required, This is sub String to be search in String2
Start = Optional. Specifies the starting position for each search. The search begins at the last character position by default (-1)
Compare = Optional. Specifies the string comparison to use. Default is 0
Can have one of the following values:
0 = vbBinaryCompare - Perform a binary comparison
1 = vbTextCompare - Perform a textual comparison
Return Values :
0 -> If String1 is ""
0 -> If String2 is not found
0 -> if start > len(String1)
Null -> If String1 is Null
Null -> If String2 is Null
Start val -> If Strin2 is ""
position val-> If string2 is found within string1
Example :
Instr(1,"The QTP Tutorial","a")
o/p 11
3) Lcase function in QTP
Converts specified string to lower case.
Syntex:
Lcase(String)
Here,
String = Required, string to be change lower case.
4) Ucase function in QTP
Converts specified string to upper case.
Syntex:
Ucase(String)
Here,
String = Required, string to be change upper case.
5) Left function in qtp
Left function used to returns number of characters from left side of the string.
Syntex:
Left(string1,length)
Here,
String1 = Required, Main string used to returns character from.
lenght = Required, Specifies how many characters to return from left side of the string.
Return values
if length = 0 -> Returns Empty String ""
if length >= len(String) -> Returns full String
if lenght < len(string) -> Returns number of character from left side
Example :
left("This is QTP tutorial",11)
o/p "This is QTP"
6) Right function in qtp
Right function used to returns number of characters from right side of the string.
Syntex:
Right(string1,length)
Here,
String1 = Required, Main string used to returns character from.
length = Required, Specifies how many characters to return from right side of the string.
Return values
if length = 0 -> Returns Empty String ""
if length >= len(String) -> Returns full String
if lenght < len(string) -> Returns number of character from right side
Example :
left("This is QTP tutorial",11)
o/p "TP tutorial"
7) Len Function in QTP
Len function used to returns the number of characters from given string.
Syntex:
Len(String)
Here,
String = Required
Example:
len("qtp")
o/p 3
8) Ltrim function in QTP
Ltrim Function used to remove spaces from left side.
Syntex:
Ltrim(String)
Here,
String = Required
Example:
len("qtp ")
o/p qtp
9) Ltrim function in QTP
Rtrim Function used to remove spaces from right side.
Syntex:
Rtrim(String)
Here,
String = Required
Example:
len(" qtp")
o/p qtp
10) Trim function in QTP
Trim Function used to remove spaces from both side.
Syntex:
Ltrim(String)
Here,
String = Required
Example:
len(" qtp ")
o/p qtp
11) Mid function in QTP
Mid function returns number of characters from given string
Syntax
Mid(string,start[,length])
Here,
String = Required, The string which char can be returned
Start = Required, Specifies the starting position.
lenght = optional, the number of characters to be returned.
Return values,
If start > len(String) = Return empty string ("")
Ex:
mid("This is QTP Tutorial",1,4)
o/p This
12) Replace function in QTP
Replace the specified number of string with in one another.
Syntex:
Replace(String,Find,ReplaceWith[,Start[,Count[,compare)
Here,
String = Required. Main String used to replace
Find = Required, THis is String which is find in the main String for replacement
ReplaceWith = Required, Substring which is going to replace in main string.
Start = Optional, From which postion from main string going to search and replace. Default is 1. All characters before the start position will be removed.
count = Optional, number of replacement in Main String. Default value is -1, which means make all possible substitutions
compare = Optional, Specifies the string comparison to use. Default is 0
Can have one of the following values:
0 = vbBinaryCompare - Perform a binary comparison
1 = vbTextCompare - Perform a textual comparison
Example :
Replace("This is a beautiful day!","i","##",2,2)
o/p "h##s ##s a beautiful day!"
13) Space function in QTP
The Space function returns a string that consists of a specified number of spaces.
Syntax
Space(number)
Here,
number = Required. The number of spaces you want in the string
Example
space(3)
o/p " "
14) Strcomp function in QTP
The Strcomp function used to comapare the two string and return the values as per the result of comparison.
Syntax:
StrComp(string1,string2[,compare])
String1 = Required.
String2 = Required.
compare = Optional, Specifies the string comparison to use. Default is 0
Can have one of the following values:
0 = vbBinaryCompare - Perform a binary comparison
1 = vbTextCompare - Perform a textual comparison
Return values,
-1 = if string1 < string2
0 = if string1 = string2
1 = if string1 > string2
Null = if string1 or string2 is Null
15) String function in QTP
The String function returns the string with contains given number of continuous character.
Syntex:
String(Number,character)
Here,
number = Required. The length of the returned string
character = Required. The character that will be repeated
Return values,
if character = "more than one letter" -> It consists first letter of that string.
Example:
String(4,H) -> O/P HHHH
String(4,"
No comments:
Post a Comment