Search code examples
vb6

What is causing the Inconsistent property declaration error?


I am getting the inconsistent property compiler error in the Let Property code.

What am I doing wrong?

Public Property Let CellEntered(ByVal uNewValue As Boolean, ByVal uCaller As String)

    If uNewValue Then
        If InIDE() Then
            SetFormCaption frmMain, "enter caller: " & uCaller
        End If
    End If

    m_bCellEntered = uNewValue

End Property
Public Property Get CellEntered() As Boolean

    CellEntered = m_bCellEntered

End Property

Solution

  • The number of parameters must be consistent between the Let and the Get.

    Let CellEntered cannot have an extra uCaller parameter.

    You can use a method to handle the uCaller parameter:

    Public Property Let CellEntered(ByVal uNewValue As Boolean)
        m_bCellEntered = uNewValue
    End Property
    Public Property Get CellEntered() As Boolean
        CellEntered = m_bCellEntered
    End Property
    
    Public Sub EnterCell(ByVal uCaller As String)
        If InIDE() Then
            SetFormCaption frmMain, "enter caller: " & uCaller
        End If
        CellEntered = True
    End Sub