easyhoting
New Member
- Joined
- Jun 25, 2012
- Messages
- 4
Hello all,
Does anyone know how to passover a dictionary from one userform to the next userform? In the program I am trying to pass on the dictionary generated in the first userform to the second userform. on initialization of the second userform, the keys from the dictionary will be populated and will be added to a combobox of the second userform. When I run this program, the dictionary was successfully created in the first userform, but it cannot be passed on to the second userform and the dictionary would show up empty. I am wondering what can be done so that the values stored in dictionary can be retained for the second userform.
Thanks
Does anyone know how to passover a dictionary from one userform to the next userform? In the program I am trying to pass on the dictionary generated in the first userform to the second userform. on initialization of the second userform, the keys from the dictionary will be populated and will be added to a combobox of the second userform. When I run this program, the dictionary was successfully created in the first userform, but it cannot be passed on to the second userform and the dictionary would show up empty. I am wondering what can be done so that the values stored in dictionary can be retained for the second userform.
Thanks
Code:
Dim dict
Dim dict_keys
'First userform
Private Sub CommandButton1_Click()
Set dict = CreateObject("Scripting.Dictionary")
dict.Add 1.01, Array("a", "b", "c", "d")
dict.Add 1.02, Array("e", "f", "g", "h")
UserForm2.Show
End Sub
'Second userform
Private Sub userform_Initialize()
dict_keys = dict.keys
For i = 0 To dict_keys.Count - 1
ComboBox1.AddItem (dict_keys(i))
Next
End Sub