Solved

C# to VB.NET Syntax

Posted on 2004-10-26
429 Views
Last Modified: 2010-08-05
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
0
Question by:F4Experts
    4 Comments
     
    LVL 8

    Expert Comment

    by:bramsquad
    change

    Implements

    to

    Inherits

    ~b
    0
     

    Author Comment

    by:F4Experts
    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
     
    LVL 8

    Expert Comment

    by:bramsquad
    where do you declare your interface?
    0
     
    LVL 85

    Accepted Solution

    by:
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Prepare to Pass the CompTIA A+ 900 Series Exam

    CompTIA aims to adapt its A+ Certification to reflect the most current knowledge and skills needed by today's IT professionals--and this year's 2016 exam is harder than ever. This certification is one of the most highly-respected and sought after in IT.

    This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    913 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now