forked from Vitosh/VBA_personal
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDictionaryExample.vb
More file actions
42 lines (29 loc) · 1.02 KB
/
DictionaryExample.vb
File metadata and controls
42 lines (29 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Option Explicit
Public Sub NumbersAndDictionary()
Dim l_counter_0 As Long
Dim l_counter_1 As Long
Dim l_counter_2 As Long
Dim l_value As Long
Dim my_dict As Object
Dim my_str As String
Set my_dict = CreateObject("Scripting.Dictionary")
For l_counter_0 = 65 To 76
my_str = CStr(l_counter_0)
For l_counter_1 = 1 To Len(my_str)
l_value = CLng(Mid(my_str, l_counter_1, 1))
If Not my_dict.Exists(l_value) Then
my_dict.Add l_value, 1
Else
my_dict(l_value) = my_dict(l_value) + 1
End If
Next l_counter_1
Next l_counter_0
Call PrintDictionary(my_dict)
Set my_dict = Nothing
End Sub
Public Sub PrintDictionary(my_dict As Object)
Dim l_counter_0 As Long
For l_counter_0 = 0 To my_dict.Count - 1
Debug.Print l_counter_0; " "; my_dict.Item(l_counter_0)
Next l_counter_0
End Sub