|
-
Oct 25th, 2012, 11:46 AM
#5
Thread Starter
PowerPoster
Re: count kay in my Dictionary
 Originally Posted by MarkT
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
Tks!
but...
COD is the code of Agency DESCR_COD is the description of Agency and i dont see that, or not?
i need:
12 - AAAA - Descr_of_AAAA
2 - BBBB - Descr_of_BBBB
17 - CCCC - Descr_of_CCCC
Sorry to post my prob in wrong mode and in a terrible enghlish
naturally all other way are welcomed
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|