gpt4 book ai didi

class - 自定义类声明 - 相同的属性过程的定义

转载 作者:行者123 更新时间:2023-12-04 20:40:49 24 4
gpt4 key购买 nike

我得到我只能假设是this error (错误消息在Excel中较长,但在其他方面对应于MSDN上描述的问题)在下面的代码中,我不明白为什么。

Private cLocation As String

' Location
Public Property Get Location() As String
Location = cLocation
End Property

Public Property Let Location(Value As String, Value1 As String)
If Value <> "" And Len(Value) > 2 Then
cLocation = Value
Else
cLocation = Value1
End If

cLocation = Test.scrubLocation(cLocation, Me.NewZipcode)
End Property

它突出了这个特殊的 Let程序。

The number of parameters for the Property Get procedure isn't one less than the number of parameters for the matching Property Let or Property Set procedure. Add a parameter to Property Let or Property Set or remove a parameter from Property Get, as appropriate.



我想这不可能 - GetLet 少 2 个参数.此外,向 Get 添加参数什么也解决不了。

The parameter types of Property Get must exactly match the corresponding parameters of Property Let or Property Set, except for the extra Property Set parameter. Modify the parameter declarations in the corresponding procedure definitions so they are appropriately matched.

The parameter type of the extra parameter of the Property Let must match the return type of the corresponding Property Get procedure. Modify either the extra parameter declaration in the Property Let or the return type of the corresponding Property Get so they are appropriately matched.



一切都是字符串,所以这也应该可以吗?

You defined a Property procedure with an Optional or a ParamArray parameter. ParamArray and Optional parameters aren't permitted in Property procedures. Redefine the procedures without using these keywords.



没有。

我还确定我没有设置 cLocation其他任何地方。整个项目中,没有其他程序对 cLocation进行修改。比 Let如上图所示。

我在做 Let错误的?我的印象是我可以从 this answer 开始这样做。 .

最佳答案

您的 Get过程必须有一个名为 Value 的字符串参数也:

Public Property Get Location(Value As String) As String
Location = cLocation
End Property

关于class - 自定义类声明 - 相同的属性过程的定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34023280/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com