如何实现我的课程 ClsInterface ,其代码为:
ClsInterface
Public Function add(x As Integer, y As Integer) As Integer End Function
Class2 ,其代码为:
Class2
Implements ClsInterface Public Function add(x As Integer, y As Integer) As Integer add = x + y End Function
我的测试代码是
Public Sub test() Dim obj As New Class2 MsgBox obj.add(5, 2) End Sub
这总是会出现以下错误:
Microsoft Visual Basic 编译错误: 好的/救命
Microsoft Visual Basic 编译错误:
好的/救命
有什么想法吗?
你的班级2必须看起来像:
Implements ClsInterface Private Function ClsInterface_add(x As Integer, y As Integer) As Integer ClsInterface_add = x + y End Function
查看Class2代码窗口顶部的下拉框,可以看到可以引用的基本对象; 或 CLS接口 .
Dim obj As New ClsInterface
ISomeDescription 以及使用 Dim Set 而不是 Dim As New .
ISomeDescription
Dim
Set
Dim As New