嵌套自定义集合类|运行时错误91对象变量或未设置块变量

时间:2017-12-29 13:37:13

标签: excel-vba vba excel

我有以下自定义类LinkEnd,其中Portal是我创建的另一个自定义类:

Option Explicit
Private ePortal As Portal
Private eHeading As Double
Public Property Get Portal() As Portal
    Portal = ePortal
End Property
Public Property Let Portal(Value As Portal)
    ePortal = Value
End Property
Public Property Get Heading() As Double
    Heading = eHeading
End Property
Public Property Let Heading(Value As Double)
    eHeading = Value
End Property

我在Link类中使用LinkEnds:

Option Explicit
Private LinkEnds As New Collection
Public Sub Add(p As Portal)
    Dim NewLinkEnd As New LinkEnd

    With NewLinkEnd
        .Portal = p
    End With

    LinkEnds.Add NewLinkEnd
End Sub
我检查过; NewLinkEnd定义得很好;问题在于

.Portal = p

如何在NewLinkEnd中正确分配Portal?我使用几乎完全相同的自定义集合类门户代码,这是Portal对象的集合,它在那里工作得很好......

0 个答案:

没有答案