Using Functions Inside A Shared Member

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

    #1

    Using Functions Inside A Shared Member

    I have a class that is just a bunch of Shared functions (basically, a bunch
    of utilities I have grouped together). However, there are functions that I
    want to write to use inside some of these Shared members that I do not want
    available outside the class. Here is the basic layout of my class:


    Public Class Utilities
    Public Shared Function Utility1() As String
    End Function

    Private Function UtilityHelper() As Integer
    End Function
    End Class


    I would like to use my function UtilityHelper() inside Utility1(), but not
    make it available outside the class. However, when I try to do this I
    recieve the following error:

    Cannot refer to an instance member of a class from within a shared method or
    shared member initializer without an explicit instance of the class.

    How can I write methods that are used only inside a class, and can be used
    in the class's Shared members? Thanks.
    --
    Nathan Sokalski
    njsokalski@hotm ail.com



  • Stephany Young

    #2
    Re: Using Functions Inside A Shared Member

    Private Shared Function ...


    "Nathan Sokalski" <njsokalski@hot mail.comwrote in message
    news:uFHLJxRGIH A.5328@TK2MSFTN GP05.phx.gbl...
    >I have a class that is just a bunch of Shared functions (basically, a bunch
    >of utilities I have grouped together). However, there are functions that I
    >want to write to use inside some of these Shared members that I do not want
    >available outside the class. Here is the basic layout of my class:
    >
    >
    Public Class Utilities
    Public Shared Function Utility1() As String
    End Function
    >
    Private Function UtilityHelper() As Integer
    End Function
    End Class
    >
    >
    I would like to use my function UtilityHelper() inside Utility1(), but not
    make it available outside the class. However, when I try to do this I
    recieve the following error:
    >
    Cannot refer to an instance member of a class from within a shared method
    or shared member initializer without an explicit instance of the class.
    >
    How can I write methods that are used only inside a class, and can be used
    in the class's Shared members? Thanks.
    --
    Nathan Sokalski
    njsokalski@hotm ail.com

    >

    Comment

    Working...