Damian
Damian

Reputation: 5174

Class module, 2 options with parameters

I'm still struggling with the classes and I'm facing this problem.

I have 1 class which calls out 2 classes:

cCentros class:

Option Explicit
'@Atento'
'clase nivel 3, los centros contienen modos y modos ACC
Private m_Modo As Object
Private m_ACC As Object

Property Get cModos(ByVal Key As String) As cModos
    With m_Modo
        If Not .Exists(Key) Then .Add Key, New cModos
    End With
    Set cModos = m_Modo(Key)
End Property

Public Property Get Count() As Long
    Count = m_Modo.Count
End Property

Public Property Get Keys() As Variant
    Keys = m_Modo.Keys
End Property

Property Get cACC(ByVal Key As String) As cACC
    With m_ACC
        If Not .Exists(Key) Then .Add Key, New cACC
    End With
    Set cACC = m_ACC(Key)
End Property

Private Sub Class_Initialize()
    Set m_Modo = CreateObject("Scripting.Dictionary")
    Set m_ACC = CreateObject("Scripting.Dictionary")
End Sub

Private Sub Class_Terminate()
    Set m_Modo = Nothing
    Set m_ACC = Nothing
End Sub

cModos class:

Option Explicit
'@Atento'
'clase de nivel 5, los modos tienen trabajadores y KPI
Private m_Agente As Object

Property Get cAgentes(ByVal Key As String) As cAgentes
    With m_Agente
        If Not .Exists(Key) Then .Add Key, New cAgentes
    End With
    Set cAgentes = m_Agente(Key)
End Property

Public Property Get Count() As Long
    Count = m_Agente.Count
End Property

Public Property Get Keys() As Variant
    Keys = m_Agente.Keys
End Property

Private Sub Class_Initialize()
    Set m_Agente = CreateObject("Scripting.Dictionary")
End Sub

Private Sub Class_Terminate()
    Set m_Agente = Nothing
End Sub

cACC class:

Option Explicit
'@Folder("Atento")
Private m_Modo As String

Public Property Get ModoPlani()
    ModoPlanificacion = m_Modo
End Property

Public Property Let ModoPlani(ByVal param As String)
    m_Modo = param
End Property

If I comment out the calling of cACC class it will work, if I don't, it throws a compile error saying something on the likes:

The definitions of procedures of the property for the same property are incoherent or the procedure of the property contains a parameter ParamArray or one final parameter Set not valid.

Could anyone give me a hint on what went wrong?

Upvotes: 0

Views: 32

Answers (1)

Brian M Stafford
Brian M Stafford

Reputation: 8868

In your cACC class, change the Property Get as follows:

Public Property Get ModoPlani() As String
    ModoPlani = m_Modo
End Property

Since you forgot the return type, the Property Get was inconsistent with the Property Let. Also, you need to change ModoPlanificacion to ModoPlani.

Upvotes: 1

Related Questions