vba - What is the difference between Dim, Global, Public, and Private as Modular Field Access Modifiers? -
in vb6/vba, can declare module-level variables outside of specific sub or function method.  i've used private , public before inside modules , understand them so:
public- visible code inside module , code outside module, making global.private- visible code inside module.
i've noticed can use dim , global modifiers modular variables.  dim , global different private , public, respectively, when used access modifiers on modular fields? if so, how different?
dim , private work same, though common convention use private @ module level, , dim @ sub/function level. public , global identical in function, global can used in standard modules, whereas public can used in contexts (modules, classes, controls, forms etc.) global comes older versions of vb , kept backwards compatibility, has been wholly superseded public.
Comments
Post a Comment