How To Create/Declare Global Variable/s in VB.Net (Web Forms)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Josh Andrews
    New Member
    • Jun 2011
    • 16

    How To Create/Declare Global Variable/s in VB.Net (Web Forms)

    Hi all,
    I am a newbie in VB.Net and was kind of lost in programming using it compared to the old VB6.

    In VB6 I was able to create, declare or assign values to global variables. But now, it seems that every variable should be included in some class (I'm not sure).

    What I need to do is to have some global variables and use them to different web pages without using the classes. What I mean is I do not like to use this sample:
    Code:
     
    Public Class FirstForm
        Public StringTest As String
        'then assign some values to StringTest
        StringTest = "abc123"
    End Class
    ..then use that StringTest variable in other webforms..

    Code:
    Dim SecondForm As New FirstForm
    Dim SecondString As String
    
    SecondString = SecondForm.StringTest
    .. something like that. Can somebody show me how to do it please? Thanks.
Working...