# QuestionFind Duplicates in arrays en count them as well

#### eMGee

##### New member
Hi,

I'm a little bit stuck with something, i seeked about a week and can't find a solution to my problem.
This is my problem:
i have an array with dates in it and i want a list with the dates and how much that date is sequel to the amount of that dates in the array.
this is my code so far:

arrsVerschillendeDagen(iTellerke) is declared on moduleniveau
arriMaand(iTellerke) is declared on moduleniveau
arriJaar(iTellerke) is declared on moduleniveau

i have a subroutine too that redimension my arrays.

Private Sub FillArray()

For iCounter As Integer = 0 To arriDag.Length - 1

arrsVerschillendeDagen(iCounter) = arriDag(iCounter) & "/" & arriMaand(iCounter) & "/" & arriJaar(iCounter)

Next

'result: 14/10/2009, 20/12/2009, 20/12/2009, 14/12/2009, 14/12/2009, 14/12/2009
'
'I want to become this
'==> 14/10/2009 1
' 20/12/2009 2
' 14/12/2009 3

For iCounter2 As Integer = 3 To arrsVerschillendeDagen.Length - 1

iGetal = 1

For iCounter22 As Integer = iCounter2 + 1 To arrsVerschillendeDagen.Length - 1

If arrsVerschillendeDagen(iCounter2) = arrsVerschillendeDagen(iCounter22) Then

iGetal += 1

If Not sString.Contains(arrsVerschillendeDagen(iCounter2)) Then
sString &= arrsVerschillendeDagen(iCounter2) & " " & iGetal & "; "
Else

End If

Else

If Not sString.Contains(arrsVerschillendeDagen(iCounter2)) Then
sString &= arrsVerschillendeDagen(iCounter2) & " " & iGetal & "; "
End If

End If

Next

Next

MessageBox.Show(sString)

End Sub

Kind regards
eMGee

Your thread says .NET 3.0. Is that true? If you're using .NET 3.5 then you have LINQ at your disposal, which is great for this sort of thing.

Replies
1
Views
278
Replies
1
Views
595
Replies
6
Views
2K
Replies
5
Views
609
Replies
2
Views
404