The Data in VB
VB computing requires that you process several types
of data. For example, you will work with names, addresses,
numbers, logical data that may be true or false. VB
supports many data types so that it can handle all
your programming needs.
Like most programming languages, VB requires that
before you work with a data value, you tell VB exactly
what type of data the value is. VB supports 12 data
types. In the following sections, we will discuss
about these data types.
Numeric Data |
Integers |
Whole numbers without decimal points such
as 15, 0, -33.
|
Decimals |
Numbers with decimal points that can represent
fractional values suc as 8.098. Decimals are
sometimes called floating point numbers.
|
Integers are stored differently inside VB, and
VB treats them differently even though people
don't always treat them differently. For example,
5 is not the same as 5.0 to VB. |
Numerica Data Types
The following table describes the seven data that
VB supports.
Type |
Storage |
Byte |
1 byte |
Integer |
2 bytes |
Long |
4 bytes |
Single |
4 bytes |
Double |
8 bytes |
Currency |
8 bytes |
Decimal |
12 bytes |
A byte is one storage location in PC's memory. |
If you know that a variable will always store whole
numbers (such as 21) rather than numbers with a fractional
amount (such as 5.57), declare it as an Integer or
Long type. Operations are faster with integers, and
these types consume less memory than other data types.
If the variable contains a fraction, declare it as
a Single, Double, or Currency variable.
The Remaining Data Types
The non numeric data types are easier to understand
than some of the higher precision numeric data types.
Type |
Storage |
Range |
String (fixed
length) |
length of string |
1 to 65,400
characters |
String (variable)
|
Length + 10 bytes |
0 to 2 billion
characters |
Date |
8 bytes |
Jan. 1, 100
to Dec., 9999 |
Boolean |
2 bytes |
True or False |
Object |
4 bytes |
Any embedded
object |
Variant (numeric) |
16 bytes |
Any value as
large as double |
Variant (text) |
Length plus
22 bytes |
Same a variable-length
String |
A String is a series of Zero or more characters. |
Boolean data, named after the mathematician George
Boole, represents data that can take only two
values. |
|