Just to expand on what everyone else has added ... As already mentioned, the hash tag (#) is a type declaration symbol (TDC) and forces the literal "1" to use the Double type. This data type conversion belongs to a class of transformations called "Explicit Conversions". Also in this class are Casts (such as CStr (), CLng (), etc.).
, . Implicit Conversion - , VBA . ( Dim j As Long), . , , ( " " ).
, , :
- Longs, . ( : http://support.microsoft.com/kb/38888)
- , , , , , .
- .
- Micro-. , , . . 99,999% , , .
, . . 1 . 2 - . .
, , . . , Literal . :
- , , .
- , Double.
- , -32,767 32,767 (), Integer.
- , -2,147,483,647 2,147,483,647 (), -32,767 32,767 Long.
- , , -2147,483,647 2,147,483,647 Double.
- .
, , , . . DataType DataTypes . DataType :
1. - DataType Variant VBA, DataType , .
2. , .
3. , DateType , DataType ( "" ).
3. (, 500 400), (, 500 * 400), (200 000) , DateType ( ). . 500 400 , , (, 500 400). , , (Long), , .
, 2, ( , ). Double . , , , .
, , , .
Micro-Optimization, , . , Double Double. , . , , , .
:
Type Declaration Character Data Type
% Integer
& Long
! Single
# Double
$ String
@ Currency
:
Dim ( - ). : Dim s As String Dim s$ String . , TDC. , Public Function MyFunc()& Public Function MyFunc() As Long.
Function Return Type
CBool Boolean
CByte Byte
CCur Currency
CDate Date
CDbl Double
CDec Decimal
CInt Integer
CLng Long
CSng Single
CStr String
CVar Variant