VBA问题,两个数组A(1,1 To 1,5)和B(1,1 To 1,5)要求比较他们包含的元素...
发布网友
发布时间:2024-03-23 15:50
我来回答
共3个回答
热心网友
时间:2024-03-25 10:19
Sub test()
a1 = Array(1, 2, 10, 7, 4)
a2 = Array(1, 2, 7, 4, 10)
tempArray1 = a1
tempArray2 = a2
For i = 0 To 4
For j = 0 To 4
If tempArray1(i) <> "" And tempArray2(j) <> "" Then
If tempArray1(i) = tempArray2(j) Then
tempArray1(i) = ""
tempArray2(j) = ""
End If
End If
Next j
Next i
For i = 0 To 4
If tempArray1(i) <> "" Or tempArray2(i) <> "" Then
Count = Count + 1
End If
Next i
If Count = 0 Then
MsgBox "the two arrays are the same"
Else
MsgBox "the two arrays are different"
End If
End Sub
热心网友
时间:2024-03-25 10:20
C.1.2.7.4.10
热心网友
时间:2024-03-25 10:28
先将这些数从排序(比如从大到小),再逐个比较即可