Remove all multiple values from a string array.
input : t, the array to tranform
output: t, the transformed array
exemple:
"one","two","one","three","two"
will be transformed in :
"one","two","three"
Sub Unique ( t( ) As String )
Dim temp() As String
Dim mem As String
Dim i As Integer
Dim cpt As Integer
Dim size As Integer
size = Ubound(t)
Redim temp(size) As String
For i = 0 To size - 1
If t(i) = "" Then
Else
mem = t(i)
End If
If mem = t(i + 1) Then
t(i) = ""
t(i + 1) = ""
End If
Next
For i = 0 To size
If t(i) <> "" Then
temp(cpt) = t(i)
cpt = cpt + 1
End If
Next
If cpt > 0 Then
cpt = cpt - 1
End If
Redim t(cpt)
For i = 0 To cpt
t(i) = temp(i)
Next i
End Sub
This was first published in November 2000