Global Variables

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

    Global Variables

    Is there a way to create global variables to be used across all forms?
  • DraguVaso

    #2
    Re: Global Variables

    Declare them public in a module

    "Matt" <mrroessner@hor mel.com> wrote in message
    news:544E8B17-E1A9-4B57-9C99-A8CAF486065D@mi crosoft.com...[color=blue]
    > Is there a way to create global variables to be used across all forms?[/color]


    Comment

    • Armin Zingler

      #3
      Re: Global Variables

      "Matt" <mrroessner@hor mel.com> schrieb[color=blue]
      > Is there a way to create global variables to be used across all
      > forms?[/color]

      Add them as Public/Friend Shared variables in a class and you can access
      them in the whole project without passing a reference (if that's what
      "global" means).


      --
      Armin

      How to quote and why:



      Comment

      • Brian Henry

        #4
        Re: Global Variables

        if you make them a shared variable they will be accessable with out
        instanciateing a class.. normally you must instanciate a class to access
        variables in it.. best pratice now days is to use classes. if you dont want
        to make it shared, then using a module will make a variable accessable
        through out the application.


        "Matt" <mrroessner@hor mel.com> wrote in message
        news:544E8B17-E1A9-4B57-9C99-A8CAF486065D@mi crosoft.com...[color=blue]
        > Is there a way to create global variables to be used across all forms?[/color]


        Comment

        • Herfried K. Wagner [MVP]

          #5
          Re: Global Variables

          * "=?Utf-8?B?TWF0dA==?=" <mrroessner@hor mel.com> scripsit:[color=blue]
          > Is there a way to create global variables to be used across all forms?[/color]

          Create a settings class and implement the singleton design pattern (see
          Google search for more info on that).

          --
          Herfried K. Wagner [MVP]
          <URL:http://dotnet.mvps.org/>

          Comment

          Working...