16
Automation Interface, Add-Ins and Tools / VBScript - Remove duplicate elements from arraylist
« on: March 10, 2017, 04:26:06 am »
Is it possible to remove duplicate elements from an arraylist?
I tried with some functions but no success.
I tried with some functions but no success.
Code: [Select]
'returns an ArrayList without duplicates
function removeDuplicates(arraylist)
dim result
set result = CreateObject("System.Collections.ArrayList")
dim element as EA.Element
for each element in arrayList
dim b
b = contains(arraylist, element)
'if contains then
'
'else
'
'end if
next
set removeDuplicates = result
end function
Code: [Select]
'returns boolean
function contains(arraylist, element)
set contains = false
dim res as EA.Element
for each res in arrayList
if res.ElementID = element.ElementID then
set contains = true
exit for
end if
next
end function