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

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -