What do ! and # mean when attached to numbers in VB6?
I have recently come across numeric literals such as 10! and 50# in Visual Basic programs. Could anyone tell me what 开发者_C百科these punctuation marks mean?
They are called type declaration characters. This article has more information.
% Integer
& Long
! Single
# Double
$ String
@ Currency
Using these characters specifies the data type of a numeric literal.
I thought this would be covered in the VB6 manual online but I can't find it.
However I just proved it with the TypeName function in the VB6 IDE Immediate Window:
? typename(10!)
Single
?typename(10#)
Double
?typename(10%)
Integer
?typename(10&)
Long
?typename(10@)
Currency
PS Be aware that a VB6 Integer
is 2 bytes, -32,768 to 32,767.
****Here is a Cheat Sheet for DataTypes ****
Variable End with:
$ : String
% : Integer (Int16)
& : Long (Int32)
! : Single
# : Double
@ : Decimal
Start with:
&H : Hex
&O : Octal
Comparison between VB and VB.Net (reference)
Visual Studio .Net added Literal Types (reference)
Value End with: (For more complete list, refer the the reference)
S : Short (Int16)
I : Integer (Int32)
L : Long (Int64)
F : Single
R : Double
D : Decimal
精彩评论