Hi there, I've come to yet another hiccup with my new project, and that is, I want to count the number of times a specific string (In this case a SHA1 Hash) occurs in a List.
BUT, I don't want to group my list as this will adversely affect the validity of the data when I save each Hash to file.
So for example lets say my list looks similar to this:
I have tried to use
But his results in:
The output I'm looking for would be:
My feeble attempt: (Please don't laugh!)
Any ideas?
BUT, I don't want to group my list as this will adversely affect the validity of the data when I save each Hash to file.
So for example lets say my list looks similar to this:
- A
- B
- C
- D
- A
- A
- E
I have tried to use
Code:
Dim groups = FileHashes.GroupBy(Function(value) value)
For Each grp In groups
HashDuplicates.Add(grp.Count)
Debug.Print(grp(0) & " - " & grp.Count)
Next
- A - 3
- B - 1
- C - 1
- D - 1
- E - 1
The output I'm looking for would be:
- A - 3
- B - 1
- C - 1
- D - 1
- A - 3
- A - 3
- E - 1
My feeble attempt: (Please don't laugh!)
Code:
For Each item In FileHashes
Dim count As Integer = 0
Dim i As Integer = 0
Do Until i = FileHashes.Count - 1
If item = FileHashes(i) Then
count += 1
HashDuplicates.Add(count)
Else
HashDuplicates.Add(1)
End If
Loop
Debug.Print(item + " checked")
Next