Prefixes modify an object tag to indicate more information about an object.
Arrays of an object type use the prefix “a”. For example:
aintFontSizes
astrNames
You indicate an index into an array by the prefix “i,” regardless of the datatype of the index. You can also use the index prefix to index into other enumerated objects, such as a collection of user-defined classes. For example:
iaintFontSizes
iastrNames
igphsGlyphCollection
Three levels of scope exist for each variable in VBA: Public, Private, and Local. A variable also has a lifetime of the current procedure or the length of the program. Use the prefixes in Table 2 to indicate scope and lifetime.
Table 2. Prefixes for scope and lifetime.
Prefix
Object Type
(none)
Local variable, procedure-level lifetime
s
Local variable, program-level lifetime (static variable)
m
Private (module) variable, program-level lifetime
g
Public (global) variable, program-level lifetime
You also use the “m”" and “g” constants with other objects, such as constants, to indicate their scope. For example:
intLocalVariable
mintPrivateVariable
gintPublicVariable
mconPi
Table 3 lists and describes some other prefixes.
Table 3. Other commonly-used prefixes.
Prefix
Object Type
c
Count of some object type
h
Handle to a Windows object
r
Parameter passed by reference
Here are several examples:
cstrArray
hwndForm
Copyright © 1995 Greg Reddick. You can freely distribute this document.
Related