What are shared (VB.NET)/Static(C#) variables?
Shared/Static classes are used when a class gives functionality which is not specific to any instance. In brief if you want an object to be shared between multiple instances you will use a Shared/Static class.
The key features of Static/Shared classes are as follows:-
1) They can't be instantiated. By default the object is created on the first method call to that object.
2) The Shared/Static classes can not be inherited.
3) The Shared/Static classes can have only static members.
4) The Shared/Static classes can have only static constructor.
Public Class ClsShared
Shared intCount As Integer
Public Function AddCount() As Integer intCount = intCount + 1
Return intCount
End Function
End Class
Public Class FrmSharedClasses
Inherits System.Windows.Forms.Form
Private Sub CmdInstance1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdInstance1.Click
Dim pobjClsShared As New ClsShared() MessageBox.Show("The count at this moment is" &
pobjClsShared.AddCount.ToString()) End Sub
Private Sub CmdInstance2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdInstance2.Click
Dim pobjClsShared As New ClsShared() MessageBox.Show("The count at this moment is" &
pobjClsShared.AddCount.ToString())
End Sub
End Class

Figure :-Shared/Static In Action