Interface Implementation Examples in Visual Basic
Classes that implement an interface must implement all its properties, methods, and events.
The following example defines two interfaces. The second interface, Interface2, inherits Interface1 and defines an additional property and method.
The next example implements Interface1, the interface defined in the previous example:
The final example implements Interface2, including a method inherited from Interface1:
Public Class ImplementationClass2 Implements Interface2 Dim INum As Integer = 0 Sub sub1(ByVal i As Integer) Implements Interface2.sub1 ' Insert code here that implements this method. End Sub Sub M1(ByVal x As Integer) Implements Interface2.M1 ' Insert code here to implement this method. End Sub ReadOnly Property Num() As Integer Implements _ Interface2.Num Get Num = INum End Get End Property End Class