I just came across some code which uses the "#" sign. I seems to be using it
when delcaring constants:
Const Variable1 As Integer = 10#
What is the # sign doing? Why would you use it?
Thanks
EM
It is used to explicitly cast the type of a variable or constant (in the case
of numbers)
From the immediate window.
? typename(10#)
Double
? typename(10%)
Integer
? typename(10!)
Single
? typename(10&)
Long
In the instance you show, since the constant is declared as integer, it
seems a bit redundant. It would more commonly be used to avoid a VBA's
implicit conversion when it causes problems.
for example
? 32000 * 10
causes an overflow error (error 6) since both variables are treated as
integers
? 32000! * 10
320000
works OK becuase 3200 is then treated as a long
You might be more familiar with variable declarations that use a $ sign for
string
Dim i$, j$
rather than
Dim i as string, j as String
? typename(i$)
String

Signature
Regards,
Tom Ogilvy
> I just came across some code which uses the "#" sign. I seems to be using it
> when delcaring constants:
[quoted text clipped - 6 lines]
>
> EM