global variable to be accessed by sub and remains unique for every instance


I am new to  how can i use a global variable which can be accessed by sub/function within the class and the variable stays unique for that session or instance.

Who is Participating?
srikanthreddyn143Connect With a Mentor Commented: can use sessions this way

2. using global variables

3. Or using classes
For Classes to be generally consumable across your site you would place them in the APP_Code folder.


The following simple class provides a global variable.


Imports Microsoft.VisualBasic


Public Class Sample


    Public Shared SomeText As String = "My Text"


End Class


Using it in a page


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init


        Me.Title = Sample.SomeText


End Sub
You can have a seperae class file and gave global variables as public.
Shiva-KumarAuthor Commented:
Could  you please show me an example
All Courses

From novice to tech pro — start learning today.