If you are just trying to figure out how to increment your counter then this should get you started. In your case, instead of using an array you would just put the the code to add or increment the dictionary inside your file reading code.
Code:Private Sub Command1_Click() Dim arrList(9) As String Dim dict As Dictionary Dim i As Integer Dim intCnt As Integer Dim varEntry As Variant arrList(0) = "AAA" arrList(1) = "AAA" arrList(2) = "AAA" arrList(3) = "BBB" arrList(4) = "CCC" arrList(5) = "BBB" arrList(6) = "BBB" arrList(7) = "AAA" arrList(8) = "AAA" arrList(9) = "BBB" Set dict = New Dictionary For i = 0 To 9 If dict.Exists(arrList(i)) Then intCnt = dict(arrList(i)) dict(arrList(i)) = intCnt + 1 Else dict.Add arrList(i), 1 End If Next For Each varEntry In dict Debug.Print dict(varEntry) & " - " & varEntry Next varEntry Set dict = Nothing End Sub




Reply With Quote