AhmedWas
AhmedWas

Reputation: 1277

Without loops, how to check if two arrays are equal or not?

I have two equal-dim arrays in VBScript and I would like to check if they contain the exact values. If they differ in only one value, then they are not equal.

I don't care about the values themselves. And I need to do it WITHOUT loops. I mean something similar to if arrx() = arry() then.

Upvotes: 1

Views: 4114

Answers (2)

CLaFarge
CLaFarge

Reputation: 1365

To tweak what MC's already provided, I'd use:

If Join(arrx,"©©©") = Join(arry,"©©©") Then 
   Something
End If

... this would prevent ["this", "one"] from accidentally matching ["thisone"]

Hope this helps.

Upvotes: 1

MC ND
MC ND

Reputation: 70923

Edited to adapt to comments.

Maybe this could (depending on real data) do the trick

If Join(arrx, Chr(0)) = Join(arry, Chr(0)) Then 

Upvotes: 6

Related Questions