Lesson 39: Numeric Data

Like other programming languages, VB is picky about data so you must go along with VB's data requirements. Before you work with a data value, your must tell VB exactly what type of data it is.

This lesson deals with numeric data. When writing programs, numbers are just not numbers! All numeric data falls into one of two categories:

When writing programs, you must keep in mind that you want the program to run as efficiently as possible. Efficiency, in computer terms, boils down to CPU and RAM usage: you do not want to place too much of a burden on either. Some data types consume a lot of memory and are inefficient, whereas others consume less memory and compute more quickly.

Here are the seven numeric data types that can be used in VB. This chart also outlines how much memory storage (bytes) each data type occupies.

Type
Storage
Range
Byte 1 byte 0 to 255
Integer 2 bytes -32 768 to 32 767
Long 4 bytes -2 147 483 648 to 2 147 483 647
Double 8 bytes

-1.79769313486232E+308 to -4.94065645841247E-324 for negative values;

4.94065645841247E-324 to 1.7976931348632E+308 for positive values

Currency 8 bytes -922 337 203 685 477.5808 to
922 337 203 685 477.5807
Decimal 12 bytes

+/-79 228 162 514 264 337 593 543 950 335 with no decimal and

+/-7.922816251426337593543950335 with up to 28 decimal places