如何用VB编程,找出两个字符串数组中不相同的部分?

2025-01-03 02:13:34
推荐回答(1个)
回答1:

就用一个较直观方法吧, 好理解.
1. 用A的每个值查B数组, 没找到就填入C
2. 同理, B查A, 生成D. (程序流程是一样的).

Option Base 1
Dim c() As String, cn As Integer, found As Boolean

cn = 0
For i = LBound(a) To UBound(a)
found = False
For j = LBound(b) To UBound(b)
If b(j) = a(i) Then
found = True
Exit For
End If
Next
If Not found Then
cn = cn + 1
ReDim Preserve c(cn)
c(cn) = a(i)
End If
Next