我已经从VB6升级到VB.NET,通过COM在Excel中使用.
原文链接:https://www.f2er.com/vb/255294.html在VB6中,我有一个在MyScalars类中定义的属性,如下所示:
Public Property Get Item(vntIndexKey As Variant) As MyScalar Attribute Item.VB_UserMemId = 0 Set Item = mCol(vntIndexKey) ... End Property
这似乎使得在Excel VBA中,我可以访问此属性而不指定它(所以像默认属性):
Dim oOut As Object Set oOut = MyScalars(Range("E10").Value)
VB.NET中有一个等效的属性吗?我尝试了以下但它在VBA中出错:
Default Public ReadOnly Property Item(ByVal vntIndexKey As String) As MyScalar Get If mCol.ContainsKey(vntIndexKey) Then Item = mCol.Item(vntIndexKey) End If ... End Property