Namespace InterfaceTest Interface ITest1 Function Proc1() As String Function Proc2( value As String ) As Boolean End Interface Interface ITest2 Function Proc5() As String Function Proc6( value As String ) As Boolean End Interface Interface IGenericTest Function GenericProc1() As T Function GenericProc2( value As T ) As Boolean End Interface Class Test1 Implements ITest1 a As Long Public Sub Test1( initValue As Long ) a = initValue End Sub Override Function Proc1() As String Return "Proc1 result" + a.ToString() End Function Override Function Proc2( value As String ) As Boolean Return ( value = ( "Proc2 calling" + a.ToString() ) ) End Function End Class Class Test2 Implements ITest1, ITest2, IGenericTest a As Long Public Sub Test2( initValue As Long ) a = initValue End Sub Override Function Proc1() As String Return "Proc1 result" + a.ToString() End Function Override Function Proc2( value As String ) As Boolean Return ( value = ( "Proc2 calling" + a.ToString() ) ) End Function Override Function Proc5() As String Return "Proc5 result" + a.ToString() End Function Override Function Proc6( value As String ) As Boolean Return ( value = ( "Proc6 calling" + a.ToString() ) ) End Function Function GenericProc1() As String Return "GenericProc1 is ok" End Function Function GenericProc2( value As String ) As Boolean Return ( value = "GenericProc2 calling" ) End Function End Class Sub GlobalProc1( itest1 As ITest1, n As Long ) UnitTest( "Interface ... GlobalProc1-1 " + n.ToString(), itest1.Proc1() = "Proc1 result123" ) UnitTest( "Interface ... GlobalProc1-2 " + n.ToString(), itest1.Proc2( "Proc2 calling123" ) ) End Sub Sub GlobalProc2( itest1 As ITest1, itest2 As ITest2, n As Long ) If ObjPtr( itest1 ) <> NULL Then UnitTest( "Interface ... GlobalProc2-1 " + n.ToString(), itest1.Proc1() = "Proc1 result123" ) UnitTest( "Interface ... GlobalProc2-2 " + n.ToString(), itest1.Proc2( "Proc2 calling123" ) ) End If UnitTest( "Interface ... GlobalProc2-3 " + n.ToString(), itest2.Proc5() = "Proc5 result123" ) UnitTest( "Interface ... GlobalProc2-4 " + n.ToString(), itest2.Proc6( "Proc6 calling123" ) ) End Sub Sub TestMain() Dim test1 = New Test1( 123 ) UnitTest( "Interface ... calling class1 method 1", test1.Proc1() = "Proc1 result123" ) UnitTest( "Interface ... calling class1 method 2", test1.Proc2( "Proc2 calling123" ) ) Dim itest1 = test1 As ITest1 UnitTest( "Interface ... calling class1 interface 1", itest1.Proc1() = "Proc1 result123" ) UnitTest( "Interface ... calling class1 interface 2", itest1.Proc2( "Proc2 calling123" ) ) GlobalProc1( test1, 1 ) GlobalProc1( itest1, 2 ) Dim test2 = New Test2( 123 ) UnitTest( "Interface ... calling class2 method 1", test2.Proc1() = "Proc1 result123" ) UnitTest( "Interface ... calling class2 method 2", test2.Proc2( "Proc2 calling123" ) ) UnitTest( "Interface ... calling class2 method 1", test2.Proc5() = "Proc5 result123" ) UnitTest( "Interface ... calling class2 method 2", test2.Proc6( "Proc6 calling123" ) ) Dim itest2 = test2 As ITest2 UnitTest( "Interface ... calling class2 interface 1", itest2.Proc5() = "Proc5 result123" ) UnitTest( "Interface ... calling class2 interface 2", itest2.Proc6( "Proc6 calling123" ) ) GlobalProc2( test2, test2, 1 ) GlobalProc2( Nothing, itest2, 2 ) Dim iGenericTest As IGenericTest iGenericTest = test2 As IGenericTest UnitTest( "Interface ... calling class2 interface 3", iGenericTest.GenericProc1() = "GenericProc1 is ok" ) UnitTest( "Interface ... calling class2 interface 4", iGenericTest.GenericProc2( "GenericProc2 calling" ) ) End Sub End Namespace InterfaceTest.TestMain()