Interface problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    Interface problem

    Hi

    I have implemented an interface as below. I am getting a "Class
    'HelloWordPlugi n' must implement 'Sub PerformAction() ' for interface
    'IPlugin'." error. What is the problem and how can I fix it?

    Thanks

    Regards


    Public Interface IPlugin
    Sub PerformAction()
    End Interface

    Public Class HelloWordPlugin
    Implements IPlugin

    Public Sub PerformAction()
    Console.WriteLi ne("Hello, World!")
    End Sub
    End Class


  • _AnonCoward

    #2
    Re: Interface problem


    "John" <John@nospam.in fovis.co.uk> wrote in message
    news:e9dFlxniFH A.3680@TK2MSFTN GP10.phx.gbl...
    : Hi
    :
    : I have implemented an interface as below. I am getting a
    : "Class 'HelloWordPlugi n' must implement 'Sub PerformAction() '
    : for interface 'IPlugin'." error. What is the problem and how
    : can I fix it?
    :
    : Thanks
    :
    : Regards
    :
    :
    : Public Interface IPlugin
    : Sub PerformAction()
    : End Interface
    :
    : Public Class HelloWordPlugin
    : Implements IPlugin
    :
    : Public Sub PerformAction()
    : Console.WriteLi ne("Hello, World!")
    : End Sub
    : End Class



    '-----------------------------------------------------------------------
    Public Interface IPlugin
    Sub PerformAction()
    End Interface

    Public Class HelloWordPlugin
    Implements IPlugin

    Public Sub PerformAction() Implements IPlugin.Perform Action
    Console.WriteLi ne("Hello, World!")
    End Sub
    End Class
    '-----------------------------------------------------------------------


    Comment

    • Armin Zingler

      #3
      Re: Interface problem

      "John" <John@nospam.in fovis.co.uk> schrieb[color=blue]
      > Hi
      >
      > I have implemented an interface as below. I am getting a "Class
      > 'HelloWordPlugi n' must implement 'Sub PerformAction() ' for interface
      > 'IPlugin'." error. What is the problem and how can I fix it?
      >
      > Thanks
      >
      > Regards
      >
      >
      > Public Interface IPlugin
      > Sub PerformAction()
      > End Interface
      >
      > Public Class HelloWordPlugin
      > Implements IPlugin
      >
      > Public Sub PerformAction()
      > Console.WriteLi ne("Hello, World!")
      > End Sub
      > End Class[/color]



      Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


      Same available via <F1>


      Armin

      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: Interface problem

        "John" <John@nospam.in fovis.co.uk> schrieb:[color=blue]
        > I have implemented an interface as below. I am getting a "Class
        > 'HelloWordPlugi n' must implement 'Sub PerformAction() ' for interface
        > 'IPlugin'." error. What is the problem and how can I fix it?[/color]

        VB.NET doesn't determine which method in a class implementing an interface
        implements a certain method of the interface by comparing the methods'
        names. Instead, you will have to declaratively specify which method of the
        interface the method implements.
        [color=blue]
        > Public Interface IPlugin
        > Sub PerformAction()
        > End Interface
        >
        > Public Class HelloWordPlugin
        > Implements IPlugin
        >
        > Public Sub PerformAction()
        > Console.WriteLi ne("Hello, World!")
        > End Sub
        > End Class[/color]

        \\\
        Public Class HelloWorldPlugi n
        Implements IPlugin

        Public Sub PerformAction() Implements IPlugin.Perform Action
        ...
        End Sub
        End Class
        ///

        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://classicvb.org/petition/>

        Comment

        Working...