返回的是「編譯錯誤:爲同一屬性的屬性過程定義不一致,或財產過程有一個可選參數,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
對象類型屬性需要'Set'來代替'Let',並且在分配返回值時還需要使用'Set'。缺少下劃線這裏'suspicous報告= suspicous_reports' –
此外,你並不需要在'natural_persons.Add(S)圍繞'S'括號' – ThunderFrame