Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
The use of the "#" sign in VBA code
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
The use of the "#" sign in VBA code
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 -- Regards, Tom Ogilvy "ExcelMonkey" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
How to "sign" macro with "digital certificate"? | New Users to Excel | |||
How do display a "+" or "-" sign when hiding columns? | Setting up and Configuration of Excel | |||
Can you "duplicate" "copy" listboxes and code to multiple cells? | Excel Programming | |||
Looking for VB code to test for "RING" , "BUSY" disconnects or other signals | Excel Programming |