05-18-2018, 12:15 PM
Store both the lists as dictionary and then use this function to compare the two dictionaries. This is the most optimum method to compare two lists in VB Script.
Code Source
A second method can be to use arrays and then using two loops compare the values of those arrays one by one (but it is not as optimized as the method above.)
Code:
Function CompareArrays(array1, array2)
'Do they have the same number of items?
If array1.Count <> array2.Count Then
CompareArrays = False
Exit Function
End If
'Compare keys and values
For Each Key in array1.Keys
'Check Keys
If NOT(array2.Exists(Key)) Then
CompareArrays = False
Exit Function
End If
'Check Value
If array1.Item(Key) <> array2.Item(Key) Then
CompareArrays = False
Exit Function
End If
Next
CompareArrays = True
End Function
Code Source
A second method can be to use arrays and then using two loops compare the values of those arrays one by one (but it is not as optimized as the method above.)
Want to fast track your QTP/UFT Learning? Join our UFT Training Course