Sub nn() Dim kk(2) As String kk(0) = "aa" kk(1) = "bb" kk(2) = "cc" Dim ak As New Scripting.Dictionary ak.Add "yoro", kk Debug.Print (ak.Item("yoro")(0)) Debug.Print (ak.Item("yoro")(1)) Debug.Print (ak.Item("yoro")(2)) kk(0) = "dd" kk(1) = "ee" kk(2) = "ff" Debug.Print (ak.Item("yoro")(0)) Debug.Print (ak.Item("yoro")(1)) Debug.Print (ak.Item("yoro")(2)) End Sub
outputは:
aa
bb
cc
aa
bb
cc
その他方法
'OK1 ak.Add "yoro", array("aa","bb","cc") 'OK2 ak.Add "yoro", New Collection ak.Item("yoro").Add "aa" ak.Item("yoro").Add "bb" ak.Item("yoro").Add "cc" Debug.Print ak.Item("yoro").Count Debug.Print ak.Item("yoro").Item(1) Debug.Print ak.Item("yoro").Item(2) Debug.Print ak.Item("yoro").Item(3) 'NG1 dim kk() as String ak.Add "yoro",kk ReDim Preserve ak.Item("yoro")(0) 'NG2 ak.Add "yoro",Array()
0 件のコメント:
コメントを投稿