1、首先比较UBound(a1)和UBound(a2)是否相同,如果相同,再比较其它就不会出错了,否则直接就是不相同。
2、For i = 0 To UBound(a1)
If a1(i) = a2(i) Then 改为
For i = 0 To UBound(a1)-1
If a1(i) = a2(i+1) Then
即可错位比较!
if UBound(a1)<>UBound(a2) then '如果这两个数组元素个数不相同
***
if UBound(a1)>UBound(a2) then ***
if UBound(a1)