我已经适应了这个vb.net,并且必须修复添加的密钥,因为它在失踪时为空。
我会在测试后编辑这篇文章。我需要确保它在VB6调用.Net dll时将其工作,并将它作为参数传递给vba集合,然后.Net dll将另一个vba集合作为返回值传回。男人,如果它有效,这将节省我很多麻烦!
Public Class VBACollection
Implements VBA._Collection
Private _items As New Dictionary(Of Object, Object)
Public Sub Add(ByRef Item As Object, Optional ByRef Key As Object = Nothing, Optional ByRef Before As Object = Nothing, Optional ByRef After As Object = Nothing) Implements VBA._Collection.Add
' Ignoring the Before and After params for simplicity
Key = If(Key, Item)
_items.Add(Key, Item)
End Sub
Public Function Count() As Integer Implements VBA._Collection.Count
Return _items.Count
End Function
Public Function GetEnumerator() As System.Collections.IEnumerator Implements VBA._Collection.GetEnumerator, System.Collections.IEnumerable.GetEnumerator
Return _items.Values.GetEnumerator()
End Function
Public Function Item(ByRef Index As Object) As Object Implements VBA._Collection.Item
Return _items(Index)
End Function
Public Sub Remove(ByRef Index As Object) Implements VBA._Collection.Remove
_items.Remove(Index)
End Sub
End Class
编辑:
没有,这不符合VB6工作。 VB6说:
“类不支持自动化或不支持预期 接口”
它谈论的是使用VBACollection代替VBA.Collection我的类的类。对于VBA.Collection,VBACollection不是相同的替代品。我想知道为什么,并试图让COM接受它。
该页面显示“只有Visual Basic 6.0应用程序才能创建VBA.Collection类的实例”。你需要收集什么?也许还有另一种方法可以做你想要达到的目标。 – Foole 2010-12-15 09:36:40
我正在使用为VBA编写的DLL。需要管理的财产之一什么是收集类型 – Maciej 2010-12-15 18:17:28