Micro Focus QTP (UFT) Forums
how to compare unsorted array with repeated values in it ? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: how to compare unsorted array with repeated values in it ? (/Thread-how-to-compare-unsorted-array-with-repeated-values-in-it)



how to compare unsorted array with repeated values in it ? - sssidana123 - 08-24-2012

Code:
Function CompareArrays(arrArray1, arrArray2)

Dim intA1
Dim intA2
Dim blnMatched

' check that the arrays are the same size
If UBound(arrArray1) <> UBound(arrArray2) then

    ' arrays are different size, so return false and exit function
    CompareArrays = False
    Exit Function

End if

' for each element in the first array
For intA1 = LBound(arrArray1) to UBound(arrArray1)

    ' initialise this to false
    blnMatched = False

    ' for each element in the second array
    For intA2 = LBound(arrArray2) to UBound(arrArray2)

        ' compare the content of the two arrays
        If arrArray1 (intA1) = arrArray2 (intA2) Then
            blnMatched = True
            Exit For
        End If

    Next ' next element in second array

    ' if the element was not found in array two, return false and exit function
    If Not blnMatched then
        CompareArrays = False
        print"fail"
        Exit Function
    End If

Next ' next element in first array

' if the function got this far, then the arrays contain the same data
    If CompareArrays = True then

             print "PASS"
    else
        
            Print "FAIL"
     End if

End Function ' CompareArrays

I am using the above function for it but not working properly.
Suggestions