i have an array with several duplicate entries and i only want the duplicates to add to a listbox.
this is my sad try but its missing entries of course:
for i as integer= window1.products.LastIndex DownTo 0
if i>0 then
if window1.products(i).NthField(";#!",2)=window1.products(i-1).NthField(";#!",2) and window1.products(i).NthField(";#!",2)<>"" then
listbox.addrow window1.products(i)
end if
end if
next
Myarray.sort
var previousString as string
For i as integer = 0 to MyArray.ubound-1
if MyArray(i) = previousString then Listbox1.addrow(MyArray(i)) // Add only the duplicate
previousString = MyArray(i)
next
Create a Dictionary that holds a count of each unique entry, then cycle through the Dictionary and add only those items to your Listbox where the count >= 2.
var counter as new Dictionary
for each item as string in window1.Products
var key as string = item.NthField(";#!", 2)
counter.Value(key) = counter.Lookup(key, 0).IntegerValue + 1
next
var counter as new Dictionary
for each item as string in window1.Products
var key as string = item.NthField(";#!", 2)
if not(counter.KeyExists(key)) then
counter.value(key)=true
else
'Handle duplicate item
end
next