'CDetailList '类模块里定义了如下私有属性 Private m_udtDetails() As NODE_DETAIL '现在要为它定义相应的get Public Property Get DetailList() As NODE_DETAIL() '之后在其他模块把DetailList当数组用却编译通不过 '编译错误:错误的参数号或无效的属性赋值 dim dlst as new CDetailList Dim cc As NODE_DETAIL cc = dlst.DetailList(0)
解决方法一,如下:
Dim dlst As New CDetailList Dim a() As NODE_DETAIL Dim cc As NODE_DETAIL a = dlst.DetailList() cc = a(0)
解决方法二,如下:
'CDetailList public property Get Item(lIndex as long) as NODE_DETAIL Item=udtDetails(lIndex) end property
需要一次取得全部明细,就返回数组;一次只要一个明细,用方法二。
感谢Tiger_Zhao的指点。