Tricentis Tosca 16.0 Released on Feb-2023 ----- UFT has been upgraded from UFT 15.0.1 to UFT One 15.0.2, Beginning at November 2020.

Monday 1 August 2016

Example VB Script Function using QTP


InStr Function:
'InStr([start,]string1,string2[,compare]) 
txt="indra"
s1=InStr(1,txt,"d")
msgbox s1
'Result s1=3

InStrRev Function:
'InStrRev(String, Substring, Start, Compare) 
val="ABCDE ABCDE"
res=InStrRev(val, "C")
msgbox res

Len Function:
s2=Len("indra")
msgbox s2

'StrReverse Function:
s2=StrReverse("indra")
msgbox s2

'StrComp Function:
s1=StrComp("indra""indra" )
msgbox s1
'If the strings are the same, the output is zero. If the strings are different, the output will be a 1 or -1 depending on the order of the strings


'Sqr Function:
val = 16
res = sqr(val)
msgbox res

'String Function:

'String(Number, Character)
'The Number argument must an integer and defines the number of times to repeat the character
res = String (10,"%")
msgbox res
'Output: %%%%%%%%%%


'Split Function :
'Split(Expression, Delimiter, Count, Compare)
Vendor_name="Aravind Engineering"
s = Split(Vendor_name)
s1= s(0)
msgbox s1

'Ucase Function
val="indra"
res=Ucase(val)
msgbox res

'Lcase Function

val="INDRA"
res=Lcase(val)
msgbox res

'Mid Function:
'Mid(String, Start, Length)
s= Mid("abcde fghij klmno pqrst uvwxyz"87)
msgbox s

'Left Function
s = Left("abcde fghij klmno pqrst uvwxyz"13)
msgbox s

'Right Function 
'Right(String, Length)
s = Right("abcde fghij klmno pqrst uvwxyz"13)
msgbox s


'FormatCurrency Function

'FormatCurrency(Expression, NumDigitsAfterDecimal, IncludeLeadingDigit, UseParensForNegativeNumbers, GroupDigit)
s= FormatCurrency(31567)
msgbox s


'FormatDateTime Function
s = FormatPercent(.77)
msgbox s


'Replace Function

'Replace(String, FindSubstring, ReplaceSubstring, Start, Count, Compare)

s = Replace("Indra is working in QTP""QTP""QC")
msgbox s