2016-08-21 4 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_reports' –

+0

Кроме того, вам не нужна скобка вокруг' S' в 'natural_persons.Add (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() и просто получить Get

Смежные вопросы