Re: RE: HOWTO: Use application global variables in VB.
Posted: 3/6/2006 9:09:35 PM
By: Comfortably Anonymous
Times Read: 1,781
0 Dislikes: 0
Topic: Programming: .NET Framework
Parent Message
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)
Discussion View:
Replies:

Re: RE: HOWTO: Use application global variables in VB.
Posted: 3/6/2006 9:09:35 PM
By: Comfortably Anonymous
Times Read: 1,781
0 Dislikes: 0
Topic: Programming: .NET Framework
I can't get this to work.  I'm a .net n00b, any everything gets the blue underline.  Other way works better
Rating: (You must be logged in to vote)

Re: RE: HOWTO: Use application global variables in VB.
Posted: 3/6/2006 9:09:35 PM
By: Comfortably Anonymous
Times Read: 1,781
0 Dislikes: 0
Topic: Programming: .NET Framework
Interesting. I've always dismissed Modules as too VB 6-ish, so never attempted them.

I went ahead and made a quick test and for WinForms apps, that's a great idea. I don't do much, if any, WinForms coding, so had never had a need to use them.

However, as far as ASP.NET apps go, it doesn't look like you can add/use modules in your code. Seems to be a WinForms-only thing. So you'll have to use my example for ASP.NET apps, but for WinForms it looks like the better way to do things is to use Modules.

Thanks!
Rating: (You must be logged in to vote)