Denoting a Variable’s Scope

In addition to prefixing a variable to denote its data type, you can and should use a prefix to denote its scope. The scope designation character precedes the data type prefix and is separated from it by an underscore. For example, to denote a module-level string variable, you can use a statement such as the following:

						Dim m_strName As String
					

Table 3-2 contains the prefixes that you use to describe scope.

Table 3-2. Prefixes for Variable Scope 
Prefix Description Example
g Global g_strSavePath
m Local to module or form m_blnDataChanged
st Static st_blnInHere
(no prefix) Nonstatic, local to procedure intIndex

Get Practical Standards for Microsoft® Visual Basic® .NET, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.