ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Naming conventions for variables (https://www.excelbanter.com/excel-programming/388672-naming-conventions-variables.html)

Dave Birley

Naming conventions for variables
 
After about 20+ years working in xBase and VFP, I have been accustomed to a
naming convention which guarantees avoiding Key Words as names. I find very
little evidence of the existence of any STANDARD naming convention in VBA --
which I think is a pity.

The convention with which I am most familiar is a three part construct:

SCOPE + TYPE + NAME.

In VFP the scope choices a

g -- Public ("Global")
p -- Private
l -- Local

The types are like:

chr -- Character
int -- Integer

The name can be pretty well anything within reason. So a Character variable
with Private scope might have a name like:

pchrDoofus

... and an Integer variable with Public scope could be

gintBigNum

The only example I have seen anywhere so far in Excel has been one helpful
individual who used "rng" as the prefix for a Range name:

For Each rngCell In Range("K2", "K13")

So, my question is this: Is there a standardized Naming Convention for VBA?
Microsoft KnowledgeBase doesn't seem to think so, but I know that the VFP
community had the current one for years before MS adopted it. Perhaps all
y'all (I live in the Sahth (that, for the benefit of my Yankee friends, is
how we pronounce "South" down here) may have either a standard one to which
to refer me, or just a preferred private one you could share with me.
--
Dave
Temping with Staffmark
in Rock Hill, SC
--
Dave
Temping with Staffmark
in Rock Hill, SC

Jim Thomlinson

Naming conventions for variables
 
Give this a quick once over...

http://support.microsoft.com/kb/110264
--
HTH...

Jim Thomlinson


"Dave Birley" wrote:

After about 20+ years working in xBase and VFP, I have been accustomed to a
naming convention which guarantees avoiding Key Words as names. I find very
little evidence of the existence of any STANDARD naming convention in VBA --
which I think is a pity.

The convention with which I am most familiar is a three part construct:

SCOPE + TYPE + NAME.

In VFP the scope choices a

g -- Public ("Global")
p -- Private
l -- Local

The types are like:

chr -- Character
int -- Integer

The name can be pretty well anything within reason. So a Character variable
with Private scope might have a name like:

pchrDoofus

.. and an Integer variable with Public scope could be

gintBigNum

The only example I have seen anywhere so far in Excel has been one helpful
individual who used "rng" as the prefix for a Range name:

For Each rngCell In Range("K2", "K13")

So, my question is this: Is there a standardized Naming Convention for VBA?
Microsoft KnowledgeBase doesn't seem to think so, but I know that the VFP
community had the current one for years before MS adopted it. Perhaps all
y'all (I live in the Sahth (that, for the benefit of my Yankee friends, is
how we pronounce "South" down here) may have either a standard one to which
to refer me, or just a preferred private one you could share with me.
--
Dave
Temping with Staffmark
in Rock Hill, SC
--
Dave
Temping with Staffmark
in Rock Hill, SC


JE McGimpsey

Naming conventions for variables
 
There's no standard.

There are some suggestions that seem to be rather widely followed. For
an example, see the pages around

http://msdn2.microsoft.com/en-us/lib...ffice.10).aspx

I use an idiosyncratic version of that style, though I find I can follow
nearly any consistent convention.

In article ,
Dave Birley wrote:

Is there a standardized Naming Convention for VBA?
Microsoft KnowledgeBase doesn't seem to think so, but I know that the VFP
community had the current one for years before MS adopted it. Perhaps all
y'all (I live in the Sahth (that, for the benefit of my Yankee friends, is
how we pronounce "South" down here) may have either a standard one to which
to refer me, or just a preferred private one you could share with me.


Dave Birley

Naming conventions for variables
 
Splendid -- just what I was looking for. JE McGimpsey's answer is more
concise, and probably the one I will print out. I had found KB110264
previously, but it seemed almost too comprehensive.

I shall feel a whole lot more comfortable using these <g! Thanks.
--
Dave
Temping with Staffmark
in Rock Hill, SC


"Jim Thomlinson" wrote:

Give this a quick once over...

http://support.microsoft.com/kb/110264
--
HTH...

Jim Thomlinson


"Dave Birley" wrote:

After about 20+ years working in xBase and VFP, I have been accustomed to a
naming convention which guarantees avoiding Key Words as names. I find very
little evidence of the existence of any STANDARD naming convention in VBA --
which I think is a pity.

The convention with which I am most familiar is a three part construct:

SCOPE + TYPE + NAME.

In VFP the scope choices a

g -- Public ("Global")
p -- Private
l -- Local

The types are like:

chr -- Character
int -- Integer

The name can be pretty well anything within reason. So a Character variable
with Private scope might have a name like:

pchrDoofus

.. and an Integer variable with Public scope could be

gintBigNum

The only example I have seen anywhere so far in Excel has been one helpful
individual who used "rng" as the prefix for a Range name:

For Each rngCell In Range("K2", "K13")

So, my question is this: Is there a standardized Naming Convention for VBA?
Microsoft KnowledgeBase doesn't seem to think so, but I know that the VFP
community had the current one for years before MS adopted it. Perhaps all
y'all (I live in the Sahth (that, for the benefit of my Yankee friends, is
how we pronounce "South" down here) may have either a standard one to which
to refer me, or just a preferred private one you could share with me.
--
Dave
Temping with Staffmark
in Rock Hill, SC
--
Dave
Temping with Staffmark
in Rock Hill, SC


Dave Birley

Naming conventions for variables
 
Jim Thomlinson pointed me to that big ol' KB110264, but I think the one I
print out is the one you linked me to. Seems a bit more concise and to the
point of VBA specifics.

Large thanks -- a great help!
--
Dave
Temping with Staffmark
in Rock Hill, SC


"JE McGimpsey" wrote:

There's no standard.

There are some suggestions that seem to be rather widely followed. For
an example, see the pages around

http://msdn2.microsoft.com/en-us/lib...ffice.10).aspx

I use an idiosyncratic version of that style, though I find I can follow
nearly any consistent convention.

In article ,
Dave Birley wrote:

Is there a standardized Naming Convention for VBA?
Microsoft KnowledgeBase doesn't seem to think so, but I know that the VFP
community had the current one for years before MS adopted it. Perhaps all
y'all (I live in the Sahth (that, for the benefit of my Yankee friends, is
how we pronounce "South" down here) may have either a standard one to which
to refer me, or just a preferred private one you could share with me.




All times are GMT +1. The time now is 05:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com