gpt4 book ai didi

ms-access - 对象模块需要为接口(interface) '~' 实现 '~'

转载 作者:行者123 更新时间:2023-12-05 00:19:35 26 4
gpt4 key购买 nike

所以我试着按照这些问题作为指导:

这是我在单击表单上的控件时遇到的错误:

error_msg

这是我的界面:

ITransactionRecord

Option Compare Database
Option Explicit

Public Property Get TRANSACTION_DATE() As Date
End Property

这是我的类(class):

分类帐记录

Option Compare Database
Option Explicit

Implements ITransactionRecord

'from interface
Private tTRANSACTION_DATE As Date

Private Property Get ITransactionRecord_TRANSACTION_DATE() As Date
ITransactionRecord_TRANSACTION_DATE = TRANSACTION_DATE
End Property

Public Property Get TRANSACTION_DATE() As Date
TRANSACTION_DATE = tTRANSACTION_DATE
End Property

Public Property Let TRANSACTION_DATE(ByVal newTRANSACTION_DATE As Date)
tTRANSACTION_DATE = CDate(Format((newTRANSACTION_DATE), "m / d / yyyy"))
End Property

传输记录

Option Compare Database
Option Explicit

Implements ITransactionRecord

'from interface
Private tTRANSACTION_DATE As Date

Private Property Get ITransactionRecord_TRANSACTION_DATE() As Date
ITransactionRecord_TRANSACTION_DATE = TRANSACTION_DATE
End Property

Public Property Get TRANSACTION_DATE() As Date
TRANSACTION_DATE = tTRANSACTION_DATE
End Property

Public Property Let TRANSACTION_DATE(ByVal newTRANSACTION_DATE As Date)
tTRANSACTION_DATE = CDate(Format((newTRANSACTION_DATE), "m / d / yyyy"))
End Property

我做错了什么?

最佳答案

Public Property Get TRANSACTION_DATE() As Date
End Property

在 VBA 的公共(public)接口(interface)成员名称中不能有下划线,因为这样你会得到:

Private Property Get ITransactionRecord_TRANSACTION_DATE() As Date

VBA 对两个下划线感到困惑,它只期待一个;在 VBA 中,实现接口(interface)成员(或处理事件源的事件)的成员将是名为 [Source]_[MemberName] 的私有(private)方法:_ 下划线字符具有接口(interface)成员签名中的句法含义,如果有的话,应该谨慎使用它,至少在任何意味着要由其他人实现的类中。

将属性重命名为 PascalCase TransactionDate,问题就消失了:

Public Property Get TransactionDate() As Date
End Property
Private Property Get ITransactionRecord_TransactionDate() As Date

关于ms-access - 对象模块需要为接口(interface) '~' 实现 '~',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51604087/

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