RE: HOWTO: Use application global variables in VB.
Posted: 4/13/2005 9:28:55 AM
By: Comfortably Anonymous
Times Read: 1,889
0 Dislikes: 0
Topic: Programming: .NET Framework
Parent Message
As I understand it, using public shared is not taking improper advantage of the "ghost class", but rather using it for what it was intended.  I believe it was explicitly created to produce functions like those provided in the programming languages which require no instantiation to use (such as INSTR or SIN).  I use it regularly for such purposes (although it hadn't occurred to me this might cause a problem in ASP applciations, so thanks for pointing that out!).    In the secenario provided, it might be more akin to the constant of PI except, of course, you may want to change the value.
Rating: (You must be logged in to vote)
Discussion View:
Replies:

RE: HOWTO: Use application global variables in VB.
Posted: 4/13/2005 9:28:55 AM
By: Comfortably Anonymous
Times Read: 1,889
0 Dislikes: 0
Topic: Programming: .NET Framework
Just a quick thought:
    Wouldn't there be a lot less overhead if you just created a module; then declared your global variables as such:

         module1()

              public num as Int16

         end Module

You can then reference them from any WinForm in the project without dimensioning or re-instanciating them at all.
for example....

Private Sub btn1_Click(byVal Sender as Object, e as EventArgs) Handles btn1.Click
            
        Dim a as int16 = 100
        Dim b as int16 = 10

        num = a*b

        messageBox.show("The new number is " & num)

End Sub
Rating: (You must be logged in to vote)