从类内部调用 Property Let
有没有办法从同一个类内部调用 Property Let 方法?
就像这个函数SetConnectionDetails
。但这会出现编译错误:无效使用属性...
Public Sub SetConnectionDetails(ByVal strServer As String, ByVal strDatabase As String, ByVal strUser As String, ByVal strPassword As String)
Server (strServer)
User (strUser)
Password (strPassword)
Database (strDatabase)
End Sub
Property Let Server(ByVal value As String)
lServer = value
End Property
Property Let User(ByVal value As String)
lUser = value
End Property
Property Let Password(ByVal value As String)
lPassword = value
End Property
Property Let Database(ByVal value As String)
lDatabase = value
End Property
Is there a way calling a Property Let method from inside the same class?
Like this function SetConnectionDetails
. But this one gets a Compile error: Invalid use of property...
Public Sub SetConnectionDetails(ByVal strServer As String, ByVal strDatabase As String, ByVal strUser As String, ByVal strPassword As String)
Server (strServer)
User (strUser)
Password (strPassword)
Database (strDatabase)
End Sub
Property Let Server(ByVal value As String)
lServer = value
End Property
Property Let User(ByVal value As String)
lUser = value
End Property
Property Let Password(ByVal value As String)
lPassword = value
End Property
Property Let Database(ByVal value As String)
lDatabase = value
End Property
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将其称为普通属性/变量:
或者,更明确地说:
请注意,我已经删除了值/参数周围的 (),因为它们不应该(通常)存在,并且 稍后可能会发现您。
You call it as a normal property/variable:
Or, more explicitly:
Note that I've removed the () around the values/parameters is they shouldn't (normally) be there, and may catch you out later.