我有一个接近工作但不完全的代码。我有两个数组 astrArray1 和 astrArray2 ,函数 findUniques() 应该返回两个数组中唯一的字符串(名称)。我可以让代码返回它们共同的名称,但它不会为唯一的名称返回正确的值。任何帮助,将不胜感激!
这是代码:
Function findUniques(astrArray1() As String, astrArray2() As String) As String
Dim blnMP5 As Boolean
blnMP5 = True
Dim counter1 As Long
Dim counter2 As Long
Dim uniquesString As String
uniquesString = " "
For counter1 = LBound(astrArray1) To UBound(astrArray1)
For counter2 = LBound(astrArray2) To UBound(astrArray2)
If astrArray1(counter1) <> astrArray2(counter2) Then
blnMP5 = False
ElseIf astrArray1(counter1) = astrArray2(counter2) Then
blnMP5 = True
End If
If blnMP5 = False Then
uniquesString = uniquesString & "," & astrArray2(counter2)
End If
Next counter2
Next counter1
findUniques = uniquesString
End Function