View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Myrna Larson Myrna Larson is offline
external usenet poster
 
Posts: 863
Default A Whole Lot a Dimming Going On

Not that I know of. You're free to make up your own, maybe wb, ws, rng, etc.


On Mon, 13 Sep 2004 15:19:21 -0700, "Nick Burns"
wrote:

Is there listing of Hungarian notation for Excel specfic objects:
Workbook
WorkSheet
Range
etc.

"CoRrRan" wrote in message
...
"Robert Lerner" wrote
in :

I apologize up front if this is a really dumb question.

My procedure [1 module/1 sub/900 lines (no comments)] involves 57
dim statements.

Lots of variables, but it runs great. It just looks strange with
all the Dim statements.

Is that too many? Is it bad coding practice? Any tips to do handle
it better?

Thank you,
Robert




Robert,

You can ignore using the DIM-statement for each variable in the
following manner:

Dim strString1 as String, strString2 as String, _
strString3 as String, strString4 as String
Dim iInteger1 as Integer, iInteger2 as Integer, iInteger3 as Integer
Dim sngSingle1 as Single, sngSingle2 as Single
Dim dblDouble1 as Double, dblDouble2 as Double

This way you can use one DIM statement to declare a number of
variables in a single line of code.

Do not use the following way, as it will provide you with a number of
unwanted Variant-datatypes:

Dim strString1, strString2, strString3 as String

In the above line, only the last variable (string 3) will have the
datatype "String", the other two are of datatype "Variant". This is
hardcoded into VBA, and even in VB, I believe.

Sometimes it is usefull to use a DIM-statement for a single variable,
as this gives you some space on the right side of the code to insert
a comment for the specific variable. However, if you do not need
comments, then it is much easier to use the first example I gave.

You can also intermix datatypes in a single line in the following
manner, but I do not find that handy myself:

Dim strString1 as String, dblDouble1 as Double, iInteger1 as Integer

HTH,

CoRrRan

P.S. I use the "Hungarian"-notation (perhaps a small derivative) for
coding variables. Take a look at: http://tinyurl.com/wmwg (Link to
MS-support)