Automating QTP Test Automation Home Automation Articles Downloads QTP Gotchas Links Books Contact About Site Map
Array Function - CompareThis function compares two arrays and reports if they are identical. Download it Here (right-click and then save target as). (NOTE - you can just cut & paste from below, but the formatting will have multiple spaces instead of tabs).
'=========================================================================
Function zGen_ArrayCompare(aArray1, aArray2) 'Compare two arrays 'Usage: 'bSame = zGen_ArrayCompare(aArray1,aArray2) 'Where: 'aArray1 = first array 'aArray2 = second array 'Returns: 'True if identical 'False if different Dim iArray1Index, iArray2Index, bMatchFound 'Check Size: If UBound(aArray1) <> UBound(aArray2) Then 'Different -> Set flag and exit zGen_ArrayCompare = False Exit Function End if 'Check Contents: 'Read through first array For iArray1Index = LBound(aArray1) to UBound(aArray1) bMatchFound = False 'Read through second array For iArray2Index = LBound(aArray2) to UBound(aArray2) If aArray1(iArray1Index) = aArray2(iArray2Index) Then bMatchFound = True Exit For End If Next If Not bMatchFound Then zGen_ArrayCompare = False Exit Function End If Next zGen_ArrayCompare = True End Function '========================================================================= |