2016-08-21 74 views
0

返回的是“编译错误:为同一属性的属性过程定义不一致,或财产过程有一个可选参数,ParamArrary,或无效的参数设定”。房产类型VBA对象

我明白这是什么错误,但只是不明白为什么给它是如此简单,遗憾和感谢希望:

Private natural_persons As Collection 
Private suspicous_reports As cls_SR 
Private legal_persons As Collection 

Private Sub Class_Initialize() 
    Set natural_persons = New Collection 
End Sub 

Public Property Let natural_person(S As cls_NP) 
    natural_persons.Add (S) 
End Property 

Public Property Get natural_person(S As Integer) As cls_NP 
    natural_person = natural_persons(S) 
End Property 

Public Property Let suspicous_report(S As cls_SR) 
    suspicous_reports = S 
End Property 

Public Property Get suspicous_report() As cls_SR 
    suspicous report = suspicous_reports 
End Property 

Public Property Let legal_person(S As cls_LP) 
    legal_persons.Add S 
End Property 

Public Property Get legal_person(S As Integer) As cls_LP 
    legal_person = legal_persons(S) 
End Property 
+1

对象类型属性需要'Set'来代替'Let',并且在分配返回值时还需要使用'Set'。缺少下划线这里'suspicous报告= suspicous_reports' –

+0

此外,你并不需要在'natural_persons.Add(S)围绕'S'括号' – ThunderFrame

回答

0

来源:https://msdn.microsoft.com/en-us/library/office/gg264197.aspx

arglist

Optional. List of variables representing arguments that are passed to the Property Get procedure when it is called. Multiple arguments are separated by commas. The name and data type of each argument in a Property Get procedure must be the same as the corresponding argument in a Property Let procedure (if one exists).

您使用性质这里是不理想(或者 - 你看 - 可能):代替​​Property Let,你可能不是考虑的AddXXX()方法,只是有获取