Page 88 - Open Soource Technologies 304.indd
P. 88
Event Driven Programming
Table 4.1
Variable types
Variable Bytes of Literal
Type Storage Suffix Range
Boolean 2 N/A True, False
Byte 1 N/A 0 to 255
Currency 8 @ – 922,337.203,685,477,5808 to
222,337,203,685,477,5807
Date 8 # 1 January 100 to 31 December 9999 and times
from 0:00:00 to 23:59:59
Decimal 12 N/A – 79,228,162,514,264,337,593,543,950,335 to
79,228,162,514,264,337,593,543,950,335
Double 8 # – 1.79769313486232E308 to
– 4.94065645841247E–324 for negative values
and from 4.94065645841247E–324 to
1.79769313486232E for positive values
Integer 2 % – 32,768 to 32,767
Long 4 & – 2,147,483,483,648 to 2,147, 483,647
Object 4 N/A N/A
Single 4 ! – 3,403823E to –1,401298–45 for negative
values and from 1.4012298E –45 to 3.402823E38
for positive values
String N/A $ A variable-length string can contain up to
approximately 2 billion characters; a fixed-length
string can contain 1 to approximately 64K
characters
User-defined N/A N/A N/A
data type
Variant N/A N/A N/A
As you can see in Table, Visual Basic has a large number of data formats. The Variant type
deserves special mention, because it is the default variable type. If you don’t declare a type for
a variable, it is made a variant:
Private Sub Command1_Click()
Dim NumberTrains
...
End Sub
82 LOVELY PROFESSIONAL UNIVERSITY