我创建了一个名为 Class1 的类,在另一个模块中,我想像这样使用该类:
Dim budgeunit As Class1
Sub Creattree()
Dim lvl1p, lvl1m, lvl1dm As Class1
Set lvl1p = New Class1
lvl1p.setName ("pear")
Set lvl1m = New Class1
lvl1m.setName ("Mango")
Set budgeunit = New Class1
budgeunit.addtochildren (lvl1p), budgeunit.addtochildren(lvl1m)
End Sub
但是当我编译它时,它突出显示了 budgeunit.addtochildren(lvl1m) 并说 Byref 参数不匹配。我已经声明了所有论点,我不知道为什么会这样。班级代码:
Dim Children() As Class1
Dim Parent() As Class1
Public level As Integer
Public name As String
Function setName(nm As String)
name = nm
End Function
Function addtochildren(node As Class1)
num = Children.Count
ReDim Children(num + 1) As String
Children(num) = node
node.addParent (Me)
End Function