我不知道你从哪里得到 IsEqual(),但你可以使用 ArrayList/Object 方法 .Equals() 来确定一个 ArrayList 是否被另一个名称/变量引用(参见 VBScript 的 Is 运算符)。
要检查两个不同 ArrayList 的计数、顺序和元素是否相等,您必须滚动自己的函数。为了让你开始:
Option Explicit
Dim alA : Set alA = CreateObject("System.Collections.ArrayList")
Dim alB : Set alB = CreateObject("System.Collections.ArrayList")
Dim alC : Set alC = CreateObject("System.Collections.ArrayList")
Dim alA2 : Set alA2 = alA
alA.Add "one"
alA.Add "two"
alB.Add "one"
alB.Add "two"
alC.Add "one"
alC.Add "owt"
WScript.Echo "alA: ", Join(AlA.ToArray())
WScript.Echo "alA2:", Join(AlA2.ToArray())
WScript.Echo "alB: ", Join(AlB.ToArray())
WScript.Echo "alC: ", Join(AlC.ToArray())
WScript.Echo "alA.Equals(alA2):", CStr(alA.Equals(alA2))
WScript.Echo "alA.Equals(alB):" , CStr(alA.Equals(alB))
WScript.Echo "alA.Equals(alC):" , CStr(alA.Equals(alC))
WScript.Echo "ALEqual(alA, alA):", CStr(ALEqual(alA, alA))
WScript.Echo "ALEqual(alA, alA2):", CStr(ALEqual(alA, alA2))
WScript.Echo "ALEqual(alA, alB):", CStr(ALEqual(alA, alB))
WScript.Echo "ALEqual(alA, alC):", CStr(ALEqual(alA, alC))
Function ALEqual(alL, alR)
ALEqual = True
If alL Is AlR Then Exit Function
ALEqual = alL.Count = alR.Count
If ALEqual Then
Dim i
For i = 0 To alL.Count - 1
If alL(i) <> alR(i) Then
ALEqual = False
Exit Function
End If
Next
End If
End Function
输出:
alA: one two
alA2: one two
alB: one two
alC: one owt
alA.Equals(alA2): Wahr
alA.Equals(alB): Falsch
alA.Equals(alC): Falsch
ALEqual(alA, alA): Wahr
ALEqual(alA, alA2): Wahr
ALEqual(alA, alB): Wahr
ALEqual(alA, alC): Falsch