C# to VB.NET Syntax

I am trying to convert some C# code to VB.NET....

I think I am declaring these properly, but I have something off:

C#:

private class AnonymousClassGWListener : GWListener
      {
            public AnonymousClassGWListener(TestDEMO enclosingInstance)
            {
                  InitBlock(enclosingInstance);
            }
            private void  InitBlock(TestDEMO enclosingInstance)
            {
                  this.enclosingInstance = enclosingInstance;
            }
            private TestDEMO enclosingInstance;
            public TestDEMO Enclosing_Instance
            {
                  get
                  {
                        return enclosingInstance;
                  }
                  
            }
            public virtual void  eventHandler(GWEvent e)
            {
                  System.Console.Out.WriteLine("Gateway listener event occurred");
                  System.Console.Out.WriteLine("user could handle this");
            }
      }

VB.NET with problem MARKED - intellisesnse says - 'TESTPROJ.frmTest.AnonymousClassGWListener' must implement 'Overridable Sub eventHandler(e As GWEvent)' for interface 'GWListener'.

   Private Class AnonymousClassGWListener
MARKED        Implements GWListener
       
      Public Overridable Sub eventHandler(ByVal e As GWEvent)
            System.Console.Out.WriteLine("Gateway listener event occurred")
            System.Console.Out.WriteLine("user could handle this")
        End Sub
       
      Public Sub AnonymousClassGWListener(ByVal enclosingInstance As frmTest)
            InitBlock(enclosingInstance)
        End Sub

        Private Sub InitBlock(ByVal enclosingInstance As frmTest)
            Me.enclosingInstance = enclosingInstance
        End Sub

        Private enclosingInstance As frmTest
        Public Property Enclosing_Instance() As frmTest
            Get
                Return enclosingInstance
            End Get
            Set(ByVal Value As frmTest)

            End Set
        End Property
    End Class
F4ExpertsAsked:
Who is Participating?
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
You have to mark the sub that satisfies the interface requirements with the Implements keyword and the requirement you are actually satisfying like this:

    Public Overridable Sub eventHandler(ByVal e As GWEvent) Implements GWListener.eventHandler

        ' ...code...

    End Sub

~IM
0
 
bramsquadCommented:
change

Implements

to

Inherits

~b
0
 
F4ExpertsAuthor Commented:
Then I get 'Classes can inherit only from other classes'

VB
Implements I1
C# -- class C1:I1 Specifies that the class (C1) implements the interface I1.  

VB
Inherits C2
C#-- class C1:C2 Specifies that the class (C1) inherits class C2.

VB
Implements I1
Inherits C2
C#-- class C1:C2,I1 Specifies that the class (C1) implements the interface I1 and inherits class C2.
0
 
bramsquadCommented:
where do you declare your interface?
0
All Courses

From novice to tech pro — start learning today.