Variables Used by All Modules
To make a module-level variable available to other modules, use the Public keyword to declare the variable.
For example:
Public myno As Integer
Module-level Variables
Module-level variables are accessible anywhere in the form/module.
Dim myno As Integer
Module-level Variables
Module-level variables are accessible anywhere in the form/module.
Dim myno As Integer
Local variables
Local variables are declared inside of a procedure or function and visible within that procedure or function only .
Function ()
Dim myno As Integer
end function
When the form is loaded, both module-level and local variables get initialized to be zero or blank depending on their data types. However, the local variables also get reinitialized each time the procedure is called.
Accessing a Variable in another Module/Form
To read or assign a value in a variable in another form, add the name of the form followed by a period before the name of the variable.
frmMain.myno = 100