【问题标题】:VB Collection cannot be indexed because it has no default property? How to iterate a collection?VB Collection 不能被索引,因为它没有默认属性?如何迭代一个集合?
【发布时间】:2010-10-07 01:41:29
【问题描述】:
    Dim RS2 As iHistorian_SDK.TagRecordset    
    '...
    For intI = 1 To RS2.Item.Count
        '....
        HistEngHigh = RS2.Item(intI).HiEngineeringUnits

现在这给出了错误接口“VBA.Collection”不能被索引,因为它没有默认属性。现在,当我通过 iFIX 在 VBA 6.5 中运行代码时它曾经可以工作,但现在我在 Visual Studio 2005 中创建了一个独立项目,它给了我这个错误。

那我该怎么办?什么是正确的默认值,为什么它没有/需要一个?

【问题讨论】:

  • 最后一个错误是哪一行。如果您查看对象定义,您是否会看到项目属性。

标签: visual-studio vba vb6 visual-studio-2005


【解决方案1】:

没关系,我通过使用 for each 循环对其进行迭代来修复它,不知道我可以将它与自定义集合一起使用

    For Each Item In RS2.Item
        WriteLogFile(Item.Description)
        ...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多