Ho aggiornato una classe da VB6 a VB.NET per essere utilizzata in Excel tramite COM.VB.NET equivalente di VB6 Attributo Item.VB_UserMemId = 0
In VB6, ho una proprietà definita in classe MyScalars
come questo:
Public Property Get Item(vntIndexKey As Variant) As MyScalar
Attribute Item.VB_UserMemId = 0
Set Item = mCol(vntIndexKey)
...
End Property
Questo sembra fare in modo che in Excel VBA, posso accedere a questa proprietà senza specificare che (così come una proprietà predefinita):
Dim oOut As Object
Set oOut = MyScalars(Range("E10").Value)
Esiste un attributo equivalente in VB.NET che esegue questa operazione? Ho provato quanto segue, ma dà un errore in 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
Che errore si ottiene in VBA? Potresti provare una proprietà con un "Set", che non è ReadOnly. – Govert
@Govert errore 450: numero errato di argomenti o assegnazione di proprietà non valida. Se faccio 'MyScalars.Item (Range (" E10 "). Value)' funziona bene, sono curioso di sapere se è possibile effettuare il default della proprietà. – ryrich
Anche la specificazione di un 'Set' dà lo stesso risultato. – ryrich