Thursday, March 29, 2012

Find Unique Values in Array using VBScript


            ''*  Find the unique values from the Array
            Dim yourArray(), objDict, OutArray, i

            yourArray() = Array("val1", "val2", "valn")
           
            Set objDict = CreateObject("Scripting.Dictionary")
            objDict.CompareMode = vbTextCompare
           
            For each val in yourArray
                objDict(val) = val
            Next
           
            OutArray = objDict.Items
            i = 0
            For i = 0 to ubound(OutArray)
                print OutArray(i)
            Next

"A good threat is worth a thousand tests" - Boris Beizer

No comments:

There was an error in this gadget