RemoveDuplicates

Removes duplicated items from a 1-dim array into new array, does not modify original array.
Found it in one of my old archives

CodeFunctionName
What is this?

Public

Not Tested

Imported
Function RemoveDuplicates(anArray)
    Dim d, item, thekeys
    Set d = Server.CreateObject("Scripting.Dictionary") ' or CreateObject("Scripting.Dictionary")
    d.RemoveAll
    d.CompareMode = 0
    For Each item in anArray
        If Not d.Exists(item) Then d.Add item, item
    Next
    thekeys = d.keys
    Set d = Nothing
    RemoveDuplicates = thekeys
End Function

anArray

Views 129

Downloads 65

CodeID
DB ID