This tutorial gives a basic understanding of variable scope.
The scope of a variable is from which sections of code it can accessed.
vb
Public Class Form1
Dim Variable_A As string="Hello from A"
Public Variable_B as string ="Hello from B"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Variable_C as string="Hello from C"
End Sub
End Class
In the above example
Variable_A It is able to be used by all functions and routines inside Form1 but not from outside of Form1 (Local to Form1)
Variable_B It is able to to used by all functions and routines inside Form1 and from outside of Form1 (via Form1.Variable_A)
Variable_C It is local to this routine, it can not be access from outside of it or the form.
But suppose you want a variable to be shared between 2 Forms, how?
You can use a module.
vb
Module ShareStuff
Public Variable_D as string="Hello from D"
Dim Variable_E as string = "Hello"
End Module
Variable_D It is able to be used both inside and outside of Shared stuff.
Variable_E It is able to to used by all functions and routines inside SharedStuff but not outside it
This is the same for different types not just strings.
I hope this help you to understand where to put things.
