【发布时间】:2017-12-30 18:58:12
【问题描述】:
我有嵌套字典的键返回到调用子函数的问题。它返回运行时错误 '424' Object Required
Set LoadCombinationDict = LCaseDict()
Set a = fs.CreateTextFile(file_name, True)
For Each LCKey In LoadCombinationDict.Keys
Line = LCKey
For Each AddnlKey In AddnlCaseDict.Keys
X = LoadCombinationDict(LCKey)(AddnlKey)
Line = Line & ";" & X
Next AddnlKey
a.WriteLine (Line)
Next LCKey
a.Close
下面是创建嵌套字典的函数
Function LCaseDict() as Scripting.Dictionary
'Some Code to create nested dictionary
End Function
如果我在子函数中包含上面的代码,字典就完美了。有没有办法将主字典和嵌套字典的键都返回给 excel vba 中的调用函数?
【问题讨论】:
-
您正确地返回了字典吗?您的错误发生在哪一行?
-
请显示您的 LCaseDict 和 LoadCombinationDict 代码。 x是什么?错误发生在哪一行?
-
错误出现在 X = LoadCombinationDict(LCKey)(AddnlKey) 行中。感谢 Thomas 的建议,它运行良好。此外,我在每个 LCKey 循环之后重置了变量“Line”。
标签: excel vba dictionary nested