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

Wednesday, October 7, 2015

Merging Two Arrays and convert as String QTP

Dim A(1)
A(0) = "Guru"
A(1) = "Prasad"
Dim B(1)

B(0) = "Naidu"
B(1) = "Kollu"
For i = 0 to ubound(A)
Str = A(i)
oTempA = oTempA&","&Str
Next
For j= 0 to ubound(B)
Str1 = B(j)
oTempB = oTempB &","& Str1
Next
        strCon = oTempA &""& oTempB
msgbox strCon

Saturday, October 3, 2015

QTP MNC Interview Quesions


  • Print next prime number in given number
  • Merge two arrays
  • Sorting of given string 

Note : Post a comment for solution on any questions

Thank you for visiting blog

How to sort the array of Integer in QTP ?

Ascending 

arr=Array(460, 68, 2, 7, 3, 5, 1)

For i=ubound(arr)-1 to 0 step-1
 For j=0 to i
  If arr(j) >arr(j+1) Then
   temp=arr(j+1)
   arr(j+1)=arr(j)
   arr(j)=temp
        End If
 Next
Next


'sorting an array in descending order

 arr=Array(4, 6, 2, 7, 3, 5, 1)
For i=ubound(arr)-1 to 0 step-1
 For j=0 to i
  If arr(j) 1) Then
                        temp=arr(j+1)
   arr(j+1)=arr(j)
   arr(j)=temp
        End If
 Next
Next


msgbox arr(0)
msgbox arr(1)
msgbox arr(2)
msgbox arr(3)
msgbox arr(4)
msgbox arr(5)
msgbox arr(6)

Sunday, September 27, 2015

Triangler Reverse given integer

strVal = 54321
for IntIcounter = len(strVal) to 1 step -1
strInd=  Left(strVal,IntIcounter)
strFinal = strFinal + strInd &VBCRLF
Next
msgbox strFinal