Also known as Type Declaration Suffixes.
This is not used so much know but does work and it saves space.
It is also possible to tell VBA the type of a variable by appending a special character to the end of the variable name.
Dim sFirstName$ 'String
Dim iNumber% 'Integer
Dim lAverage& 'Long
Dim sngTotal! 'Single
Dim dbTotal# 'Double
Dim cProfit@ 'Currency
Dim llDiscount^ 'LongLong on 64 bit
Data type Abbreviation Declaration Characters
VBA does allow you to append a character to a variable's name as a quick way of indicating its data type.
This method of declaring variables should not be used and is only available for backwards compatibility purposes.
The following line will declare a variable with a Double data type
This line however should be declared using the "As" keyword.
Dim dbDouble As Double
Data type Abbreviations / Suffixes
If you use the abbreviations then you do not have to declare the type. If you use count% then you do not have to type "as integer".
These are still supported in Visual Basic 2005
These abbreviations can be useful for assigning literals to variants
MyVariant = 10#
© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext