gpt4 book ai didi

vba - 访问数组中的字典VBA

转载 作者:行者123 更新时间:2023-12-03 00:42:31 25 4
gpt4 key购买 nike

我想通过使用键“first”来访问字典值“Watermelon”,而字典位于数组中。我相信这是将字典插入数组的正确方法。我已经尝试了我能想到的所有语法组合,但在任何地方都找不到如何访问位于数组中的字典的答案。

Function dictTest() As Object
Dim m_info As Dictionary
Set m_info = New Dictionary
m_info.Add "first", "watermelon"
Set dictTest = m_info
End Function

Sub checker()
Dim x(1 to 1) As Object
Set x(1) = dictTest
End Sub

最佳答案

这应该适合你:

Function dictTest() As Object
Dim m_info As Object
Set m_info = CreateObject("Scripting.Dictionary")
m_info.Add "first", "watermelon"
Set dictTest = m_info
End Function

Sub checker()
Dim x(1 To 1) As Object
Set x(1) = dictTest
MsgBox x(1)("first")
End Sub

关于vba - 访问数组中的字典VBA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51862831/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com