About This Code
Brief Description:
Array1 = Array2 ?
Notes Version:
R4.x, R5.x, R6.x
Last Modified:
16 Dec 2002
OpenNTF Disclaimer
All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.
Code / Description
Function IsArrayEqv(a1, a2) As Variant 'boolean
%REM
Compares two arrays to make sure they are equal.
Uses <> to make comparisons, so this function will not work with arrays of objects, arrays, or lists.
%END REM
Dim i As Long
Dim iLower1 As Long
Dim iUpper1 As Long
IsArrayEqv = False
If Not Isarray(a1) Or Not Isarray(a2) Then Exit Function
iUpper1 = Ubound(a1)
If iUpper1 <> Ubound(a2) Then Exit Function
iLower1 = Lbound(a1)
If iLower1 <> Lbound(a2) Then Exit Function
For i = iLower1 To iUpper1
If a1(i) <> a2(i) Then Exit Function
Next
IsArrayEqv = True
End Function
Usage / Example
For a QuerySave event:
...
asNewFieldValues = Doc.FieldName
If Not IsArrayEqv(asOldFieldValues, asNewFieldValues) Then
Call UpdateDependentDocuments
asOldFieldValues = asNewFieldValues
End If