Friday, November 25, 2011

Functions in QTP........

 'FAQ, Functions


 'Functions (strcomp, mid, split, instr, replace,filter etc)
 temp="Welcome BAck"
 temp1="Welcome Back"
 temp2="Welcome, Mr. James, Way, JamBach"
 temp3="come"

 'SPLIT()
 text=split(temp2,",")
 limit=ubound(text)
 For i=0 to limit
 msgbox text(i)
 Next

 'FILTER
 text1=filter(text,"Jam")
 limit=ubound(text1)
 For i=0 to limit
 msgbox text1(i)
 Next

 'REPLACE()
 text=replace(temp,"JP","a")
 msgbox text

 'INSTR()
 text=Instr(1,temp1,temp3)
 msgbox text

 'MID()
 text=mid(temp1,4,3)
 msgbox text


 'STRCOMP()  Binary & Text Comprison
 If strcomp(temp,temp1,0)=0 Then
  msgbox "Pass"
  else
  msgbox "Failed"
 End If