VBA Tip: Object-Variable Naming

Written by Rod Wing.

Variable (or object) naming standards in the programming world can be compared to layer/level naming standards in the CAD world. Just as the U.S. National CAD Standards specification is the benchmark for CAD layer/level names, Hungarian Notation is the benchmark for programming code.

The basic syntax of Hungarian notation is that each variable uses a standard prefix coding scheme (or mnemonic) of lower case letters that denote the scope and type of the variable, followed by the name which begins with an upper case letter. Typically a first letter of “g” denotes a global (or public) variable, while a first letter of “m” indicates a module level variable. Using the variable name mlngCount we would know without looking at the Dim statement that this is a module level variable of type Long and that its name is Count. Likewise there are VBA specific extensions to the specification. Using the example object cmdCancel it would be easy to guess that this refers to a form’s Cancel command button.

Just like layer/level naming standards each organization has their own variable naming standards. The most important thing to remember about a variable naming standard is not which one you use, but just use one and stick with it.

 

For an overview of Hungarian notation you can visit:

https://en.wikipedia.org/wiki/Hungarian_notation

 

VB/VBA specific specifications can be found here:

https://support.microsoft.com/kb/173738

https://www.xoc.net/standards/rvbanc.asp

 

Last Month’s Tips:

       Undo  OpenRoads Terrain Elements     Comparing Floating Point Numbers     Selection Port-Starboard or Starboard-Port

MicroStation: Backup & Undo        InRoads: OpenRoads                VBA: Comparing                          MicroStation Pirate:
                                                                Terrain Elements                       Floating Point Numbers              Selection Port-Starb… 
 
 
Don’t want to miss out on other great information? Subscribe to this blog or our monthly eNewsletter now!
Learn More ◊ Contact us today ◊ Newsletter ◊
EnvisionCAD Group EnvisionCAD YouTube Channel   

 

EnvisionCAD

Since 1996, EnvisionCAD has been a nationally recognized leader in the configuration, customization, implementation, training & support for CAD software solutions. Our individualized approach has benefited private engineering firms and government agencies alike. Basic or advanced, we can help you get the most from your CAD technology.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *