vba interfaces and properties code example
Example: vba interface
Option Explicit
Public Property Get Name() As String
End Property
Public Property Let Name(pName As String)
End Property
Public Function ToString() As String
End Function
Option Explicit
Implements IMyClass
Private mName As String
Public Property Get IMyClass_Name() As String
IMyClass_Name = mName
End Property
Public Property Let IMyClass_Name(pName As String)
mName = pName
End Property
Public Function IMyClass_ToString() As String
IMyClass_ToString = "My name is " & mName
End Function
Sub TestMe()
Dim c As New MyClass
c.IMyClass_Name = "James B"
Debug.Print c.IMyClass_ToString
End Sub