Exposing sub outside form

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

    Exposing sub outside form

    Hi

    How can I expose a sub outside a form so it is available globally?

    Thanks

    Regards


  • =?Utf-8?B?aXdkdTE1?=

    #2
    RE: Exposing sub outside form

    just declare it

    Public Sub Foo()

    End Sub

    and anything can see it. Hope this helps

    --Jon

    Comment

    • Cor Ligthert[MVP]

      #3
      Re: Exposing sub outside form

      John,

      Make it from private public, be aware however that you are violating direct
      all rules of OOP than,.

      Cor

      "John" <John@nospam.in fovis.co.ukschr eef in bericht
      news:eyN3G5fZIH A.220@TK2MSFTNG P04.phx.gbl...
      Hi
      >
      How can I expose a sub outside a form so it is available globally?
      >
      Thanks
      >
      Regards
      >

      Comment

      • GS

        #4
        Re: Exposing sub outside form

        try this

        Friend sub mysub
        end sub


        the keywords "Protected Friend" allows any code within the application
        namespace to access the sub

        But if you want any code including those outside your project you may want
        to try
        Public instead of "Protected Friend"

        "John" <John@nospam.in fovis.co.ukwrot e in message
        news:eyN3G5fZIH A.220@TK2MSFTNG P04.phx.gbl...
        Hi
        >
        How can I expose a sub outside a form so it is available globally?
        >
        Thanks
        >
        Regards
        >
        >

        Comment

        • Michael D. Ober

          #5
          Re: Exposing sub outside form

          "Cor Ligthert[MVP]" <notmyfirstname @planet.nlwrote in message
          news:ACB63864-4804-4E95-83E3-AB95F7A7101D@mi crosoft.com...
          John,
          >
          Make it from private public, be aware however that you are violating
          direct all rules of OOP than,.
          >
          Cor
          >
          Cor,

          Simply making a private sub public doesn't violate OOP. You are allowed
          to extend and republish a published interface and it won't break existing
          code. Going the other way could break existing code. In addition, a sub
          doesn't return anything, so unless there are byref arguments, no information
          about the internal structure and state of the form object can be returned,
          making it impossible for violation of encapsulation.

          Mike
          "John" <John@nospam.in fovis.co.ukschr eef in bericht
          news:eyN3G5fZIH A.220@TK2MSFTNG P04.phx.gbl...
          >Hi
          >>
          >How can I expose a sub outside a form so it is available globally?
          >>
          >Thanks
          >>
          >Regards
          >>
          >
          >


          Comment

          • Cor Ligthert [MVP]

            #6
            Re: Exposing sub outside form

            Michael,

            (and now the true one).

            You are right, however I don't like all those public member to do this kind
            of things (and I am violating to it as needed).

            Cor


            Comment

            Working...