2016-08-21 91 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()方法,只是有獲取