7,785
社区成员




'去除重复字符串
Public Function RemoveRepeat(ByVal AStr As String) As String
Dim arrTemp() As String
Dim I As Long
Dim J As Long
Dim LStr As String
LStr = ""
arrTemp = Split(AStr, ",")
For I = 0 To UBound(arrTemp)
For J = I + 1 To UBound(arrTemp)
If arrTemp(I) = arrTemp(J) Then
arrTemp(J) = ""
End If
Next J
Next I
For I = 0 To UBound(arrTemp)
If arrTemp(I) <> "" Then
LStr = LStr & arrTemp(I)
If I < UBound(arrTemp) Then
LStr = LStr & ","
End If
End If
Next I
RemoveRepeat = LStr
End Function
Private Function filter(ByVal s As String)
Dim a, i, j, k
Dim b()
a = Split(s, ",")
For i = 0 To UBound(a) - 1
For j = i + 1 To UBound(a)
If a(i) = a(j) Then a(j) = ""
Next
Next
For i = 0 To UBound(a)
If a(i) <> "" Then
ReDim Preserve b(k)
b(k) = a(i)
k = k + 1
End If
Next
filter = b
End Function
Private Sub Form_Load()
Dim s, a
s = "000001,000001,000002"
a = filter(s)
S1 = Join(a, ",")
MsgBox S1
End Sub