【问题标题】:VBA Adding a class to a collection [duplicate]VBA将类添加到集合中[重复]
【发布时间】:2011-06-13 13:31:08
【问题描述】:

我有一个名为Holding 的类模块。其中有几个公共变量。我的代码是这样的:

Dim holdings as Collection
Dim h as Holding

Set holdings = new Collection

For i = 1 to last
    Set h = new Holding

    h.x = y
    '... etc

    holdings.Add(h)
Next i

这给了我holdings.Add(h) 行上的错误“对象不支持此属性或方法”,但在我所看到的任何地方,它都给出了如何实现这一点的确切示例。我错过了什么?

【问题讨论】:

    标签: vba collections


    【解决方案1】:

    去掉括号。

    holdings.Add h
    

    否则,您会尝试将 Holding 实例的默认属性值添加到集合中,但它没有默认属性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-27
      • 2018-08-11
      • 2023-03-20
      • 2014-05-11
      • 2011-08-31
      • 1970-01-01
      • 2011-03-23
      • 1970-01-01
      相关资源
      最近更新 更多