# Thread: How to comparre two Bi-Directional array

1. ## How to comparre two Bi-Directional array

Hi All,

I have two bi-directional arrays ActualArray and ExpextedArray . They both are suppose to be same means
ActualArray(0,1) should be equal to ExpextedArray(0,1) Similarly
ActualArray(1,0) should be equal to ExpextedArray(1,0) and so on
My array elements are consist of rows and columns where column is always constant but row is dynamic

Any one have any idea how to start validating these elements?

Thanks,
SIK

2. ## Re: How to comparre two Bi-Directional array

<font class="small">Code:</font><hr /><pre>Dim MyArray1(2,2)
MyArray1(0,0) = 10001
MyArray1(0,1) = 1200
MyArray1(1,0) = 1500
MyArray1(1,1) = 2000

Dim MyArray2(2,2)
MyArray2(0,0) = 1000
MyArray2(0,1) = 1200
MyArray2(1,0) = 1500
MyArray2(1,1) = 2000

'Check First Dimension Upper Bound and Second Dimension Upper Bound are equal
If (uBound(MyArray1,1) &lt;&gt; uBound(MyArray2,1)) Or (uBound(MyArray1,2) &lt;&gt; uBound(MyArray2,2)) Then
Msgbox "Arrays are not equal"
ExitTest
End If

Flag = True
For i = 1 To uBound(MyArray1)
'Check Array content
For j = 1 To uBound(MyArray1,i)
If MyArray1(i-1,j-1) &lt;&gt; MyArray2(i-1,j-1) Then
Flag = False
End If
Next
Next

If Flag Then
Msgbox "Arrays are equal"
Else
Msgbox "Arrays are not equal"
End If</pre><hr />

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.