Standard
Each variable should be declared on its own line to aid clarity and reduce the chance of unintentional behaviour. For example:
Dim x As Long
Dim y As Long
Dim ratio As Double
Rationale
VBA has a peculiar way of declaring types when multiple variables are declared on the same line. The following two pieces of code are not equivalent:
Dim x, y, z As Long
Dim x As Long, y As Long, z As Long
In the first example, x and y become Variant type and z is a Long (which is probably not what the author intended). In the second example they are all Longs. This is not consistent with many other programming languages and is likely to cause confusion for other programmers, or even the original author.
No comments:
Post a Comment