vba 无效使用财产?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10476850/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 16:03:22  来源:igfitidea点击:

Invalid Use of Property?

vbaaccess-vba

提问by Anders

I am working with an Access database and it has a form and VBA behind it. It has been quite a while since I dabbled in VBA and my google-fu is failing me right now so bear with me.

我正在使用 Access 数据库,它背后有一个表单和 VBA。自从我涉足 VBA 以来已经有一段时间了,我的 google-fu 现在让我失望了,所以请耐心等待。

I created a simple class, and I am getting a compile error:

我创建了一个简单的类,但出现编译错误:

Dim oRecordSet As ADODB.RecordSet
Public Property Get RecordSet() As ADODB.RecordSet
    RecordSet = oRecordSet '' error here
End Property

Public Property Let RecordSet(ByVal val As ADODB.RecordSet)
    RecordSet = val
End Property

I have a couple other identical properties (different names/variables, obviously) that compile just fine; their types are Stringand Integer.

我还有其他几个相同的属性(显然是不同的名称/变量),它们编译得很好;它们的类型是StringInteger

What am I missing? Thanks!

我错过了什么?谢谢!

Also a side note, when I am coding the intellisense shows ADODB.Recordset, but on autoformat (carriage return, compile, etc) it changes it to ADODB.RecordSet. Need I be worried?

还有一个旁注,当我编码智能感知显示时ADODB.Recordset,但在自动格式化(回车、编译等)时,它会将其更改为ADODB.RecordSet. 我需要担心吗?

回答by Edwin Bautista

It should be:

它应该是:

Public Property Get RecordSet() As ADODB.RecordSet
    Set RecordSet = oRecordSet '' error here
End Property