引起”Inconsistent property declaration error”错误的原因是什么?

huangapple go评论51阅读模式
英文:

What is causing the Inconsistent property declaration error?

问题

我在 Let Property 代码中遇到了不一致的属性编译错误。

我做错了什么?

    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
英文:

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

答案1

得分: 2

属性的参数数量必须在“Let”和“Get”之间保持一致。

“Let CellEntered”不能有额外的“uCaller”参数。

您可以使用一个方法来处理“uCaller”参数:

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, "输入调用者: " & uCaller
    End If
    CellEntered = True
End Sub
英文:

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

答案2

得分: 1

根据错误消息的提示,参数必须保持一致。您可以采取以下措施使它们保持一致:

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

Public Property Get CellEntered(ByVal uCaller As String) As Boolean
   CellEntered = m_bCellEntered
End Property

需要注意的是,任何额外的参数必须放在值的前面。

英文:

As the error message indicates, the parameters must be consistent. You can do the following to make them consistent:

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

Public Property Get CellEntered(ByVal uCaller As String) As Boolean
   CellEntered = m_bCellEntered
End Property

It should be noted that any additional parameters must come BEFORE the value.

huangapple
  • 本文由 发表于 2023年5月20日 23:38:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76296022.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定