Naming
- Last UpdatedJul 18, 2023
- 1 minute read
Function, subroutine, variable, constant, and label naming in VBA must begin with a letter, be no longer than 40 characters, and cannot be a reserved word. Name field are not case-sensitive and can only contain the letters 'A' to 'Z' and 'a' to 'z', the underscore '_' character, and the digits '0' to '9'. Names cannot contain the space character. You cannot use the name of a VBA predefined function as a name. For a list of predefined functions, see .
Function, subroutine, variable, constant, and label object names (once declared), become a keyword in VBA. Like most keywords in VBA, these names are not case sensitive. For example, all of the following examples are treated identically in VBA:
pump234.addpoint(25, 100)
Pump234.AddPoint(25, 100)
PUMP234.ADDPOINT(25, 100)
When naming in VBA, make the name an appropriately descriptive term that is easily recognizable. For example:
X.addpoint(25, 100)
This does not make as much sense as:
Pump234.AddPoint(25, 100)
Combining upper- and lowercase letters between words in the name is an acceptable common programming practice, and aids in readability.
Identically named objects cannot be declared more than once per Plant SCADA project, even though they may exist in different VBA code file modules. However, if an object declared locally within a procedure has the same name as an object declared in a module, VBA will reference the local procedure scope object instead of the modular scope object.