gpt4 book ai didi

excel - 声明包含后期绑定(bind)字典对象的自定义数据类型

转载 作者:行者123 更新时间:2023-12-04 21:49:07 26 4
gpt4 key购买 nike

自定义类型可以声明为具有后期绑定(bind)的字典对象作为其元素之一吗?例如在标准模块或类模块中:

Private Type InternalData
sName as String
cSheets as Collection 'cSheets as New Collection
wBook as Workbook
bFiles as CreateObject("Scripting.Dictionary") 'bFiles as New CreateObject("Scripting.Dictionary")
End Type

或者有其他方法吗?请注意,我不想提前绑定(bind)字典。

最佳答案

您将像处理工作簿对象一样处理字典对象。将您的字典声明为类型 Object然后在其他地方初始化它。例如,在表单中,您可以:

Private Type InternalData
sName As String
cSheets As Collection
wBook As Workbook
bFiles As Object
End Type

Public Sub TryIt()
Dim id As InternalData
Set id.bFiles = CreateObject("Scripting.Dictionary")
id.bFiles.Add Key, Value
End Sub

根据评论,您可以通过以下方式完成类(class)。在类模块中:
Public sName As String
Public cSheets As Collection
Public wBook As WorkBook
Public bFiles As Object

Private Sub Class_Initialize()
Set bFiles = CreateObject("Scripting.Dictionary")
End Sub

然后像以前一样,也许在一个表格中:
Public Sub TryIt()
Dim id As InternalData
id.bFiles.Add Key, Value
End Sub

关于excel - 声明包含后期绑定(bind)字典对象的自定义数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57956451/

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