Advertisement
veronikaaa86

03. Equal Arrays

Sep 27th, 2022
1,960
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub EqualArrays()
  2.     Dim firstArr, secondArr As Variant
  3.     firstArr = Array(10, 20, 30)
  4.     secondArr = Array(10, 20, 40)
  5.    
  6.     Dim index As Integer
  7.    
  8.     Dim isIdentical As Boolean
  9.     For i = 0 To UBound(firstArr)
  10.         If firstArr(i) <> secondArr(i) Then
  11.             isIdentical = False
  12.             index = i
  13.             Exit For
  14.         Else
  15.             isIdentical = True
  16.         End If
  17.     Next
  18.    
  19.     If isIdentical Then
  20.         Debug.Print "Yes"
  21.     Else
  22.         Debug.Print "No - " & index
  23.     End If
  24. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement