28 Nov 2012

Resuable Functions in QTP


Write a Function add/Multiply/subtraction/division of two numbers


Function action(a,b,c)

d=a&c&b

e=eval(d)

action=e

End Function

msgbox action(10,20,"+")


Write a Function club two variables


Function club(a,b)
c=a&" "&b
club=c
End Function

msgbox club("India","Great")

Write a Function Given number is even or odd
Function evenodd(a)
If a mod 2=0 then
evenodd="Even"
Else
evenodd="Odd"
End If
End Function

msgbox evenodd(11)


Write a Function to get the first part of the string separated by Delimiter

Function getfirst(str)
a=split(str)
getfirst=a(0)
End Function

msgbox getfirst("venkat kandula")

No comments:

Post a Comment