Friday, November 27, 2015

Code for import excel from QC to QTP

Set tdc = QCUtil.QCConnection 
set tm = tdc.TreeManager 
set root = tm.TreeRoot("Subject") 
set folder = root.FindChildNode("Your folder name") 
Set fact = folder.Attachments



How to find highest and lowest value from an array

Lowest value

Arr = Array(5,2,6,333)

for i = 0 to ubound(Arr)

if Arr(i) < Arr(0) Then

  Arr(0) = Arr(i)

End if

next

msgbox   Arr(0) 'output 2

Highest value

Arr = Array(5,2,6,333)

for i = 0 to ubound(Arr)

if Arr(i) < Arr(0) Then

  Arr(0) = Arr(i)

End if

next

msgbox   Arr(0) 'output 333 

Monday, November 23, 2015

How to remove duplicates values in array in qtp

Removing Duplicate Digits

dim a
aList=Array(12,10,15,10,125,7)
Dim sNewList
dim newArray
b= ubound(aList)

For x=0 to b

If InStr(sNewList,(aList(x) & ",")) <= 0 Then
sNewList = sNewList&" , "&aList(x)
End If
Next

MsgBox sNewList

Removing Duplicate Char


str = "guruprasad"

Dim sNewList
For i =1  to len(str)
strChar = Mid(str,i,1)
   If InStr(sNewList, strChar) <= 0 Then
       sNewList = sNewList&""& strChar
   End If
  Next

MsgBox sNewList