VB6 接口成员定义
接口ICommission有ActiveConnection属性和Depart_ID属性
Private conn As ADODB.Connection
Private m_Depart_ID As String
Public Property Get Depart_ID() As String
Depart_ID = m_Depart_ID
End Property
Public Property Let Depart_ID(ByVal StrValue As String)
'End Property
Public Property Get ActiveConnection() As ADODB.Connection
End Property
Public Property Set ActiveConnection(ConValue As ADODB.Connection)
End Property
在其他类cA中实现该接口
Private m_Depart_ID As String
Private conn As New ADODB.Connection
Public Property Get ICommission_Depart_ID() As String
ICommission_Depart_ID = m_Depart_ID
End Property
Public Property Let ICommission_Depart_ID(ByVal StrValue As String)
m_Depart_ID = StrValue
End Property
Public Property Get ICommission_ActiveConnection() As ADODB.Connection '动态连接
Set ICommission_ActiveConnection = conn
End Property
Public Property Set ICommission_ActiveConnection(ConValue As ADODB.Connection)
Set conn = ConValue
End Property
为何总是提示要实现Depart_ID接口?而把接口中的Depart_ID成员去掉就可以,这说明ActiveConnection成员已经实现了,为何单单Depart_ID不行?
要抓狂了
[解决办法]
函数名中下划线首先当中接口的分隔符,ICommission_Depart_ID 被拆成 3 部分了,当然与接口不匹配。
VB 中一贯不推荐公共成员名称带下划线,Depart_ID 更改为 DepartID 就可以了。