|
|
Joined: Dec 1999
Posts: 30,867
Master Elite Member
|
Public Function SArr_PurgeDups(SArray() As String, CaseSen As Boolean) As String()
'Function
' Removes all duplicate elements from a String Array and returns the result.
' If the specified Array is Empty, returns an Empty Array.
'Parameters
' SArray (String()) = The String Array to make unique.
' CaseSen (Boolean) = If True, the comparison is case-sensitive.
' If False, the comparison is not case-sensitive.
' In this case, if MyString is found in SArray without regard to case, function returns True.
'Version History
' 1.0 4/1/2006 7:39am Tested by Russ Tanner on VB6 Win2000
'---
'Initiate variables
Dim R() As String 'return value
Dim i As Long 'loop counter
'Trap: Specified Array is Empty, return an Empty Array
If IsEmptyArray(SArray) Then
SArr_PurgeDups = R
Exit Function
End If
'Loop through all elements of the specified array and add non-duplicates to the return buffer...
For i = LBound(SArray) To UBound(SArray)
'The current source element is not in the output Array, add it now
If Not SArray_StrExists(R, SArray(i), CaseSen) Then
ReDim Preserve R(ElementCount(R))
R(UBound(R)) = SArray(i)
End If
Next i
'Return the result
SArr_PurgeDups = R
End Function
|
|
|
|
Entire Thread
|
Removes all duplicate elements from a String Array and returns the result.
|
Russ
|
08/11/08 10:29 PM
|
|
|
|