英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论