Is there any difference between dim shared and common shared?
Is there any difference between dim shared and common shared?
Is there any difference between dim shared and common shared?
Re: Is there any difference between dim shared and common shared?
- 'Dim Shared' declares (and defines) a global variable inside one code module (it can be used inside the Subs and Functions of the module where it is declared, as well as at main level of this module).
- 'Common Shared' declares (and defines) also a global variable as above, and in addition it can be shared between several code modules (a 'Common Shared' declaration with same variable name must be put in each module where sharing is requested).
- If 'Dim Shared' with the same variable name is declared in several code modules, each global variable remains independent in its code module.
For more information about the visibility of a variable, see at Introduction to Variable Scope.
- 'Common Shared' declares (and defines) also a global variable as above, and in addition it can be shared between several code modules (a 'Common Shared' declaration with same variable name must be put in each module where sharing is requested).
- If 'Dim Shared' with the same variable name is declared in several code modules, each global variable remains independent in its code module.
For more information about the visibility of a variable, see at Introduction to Variable Scope.
Re: Is there any difference between dim shared and common shared?
Thank you very much for your detailed explanation ~ let me know more about FB