Variables provide temporary storage for information that will be needed during the lifespan of the computer program (or application). This article is short reference table of the types of variables used in programming.
Variables are also used in programming to transfer information from one part of the program to another – for example to provide a place to lay out a document before printing it – as well as being a place to store status information that might be needed by all parts of that program.
While some of the concepts might seem language-specific, they apply to all programming languages to varying degrees, and the terminology is programming language-neutral.
A programmer can imagine a variable as being a box into which information can be placed, and the shape of the box (the variables type) determines what kind of information it can store.
Numeric Data Types
Type | Size | Range of Values | Prefix | Example Variable Name |
Byte | 1 byte | 0 to 255 | byt | bytFirstChar |
Integer | 2 bytes | -32,768 to 32,767 | int | intCount |
Long | 4 bytes | -2,147,483,648 to 2,147,483,648 | lng | lngHwnd |
Single | 4 bytes | Negative values: -3.402823E+38 to -1.401298E-45 Positive values: 1.401298E-45 to 3.402823E+38 | sng | sngPi |
Double | 8 bytes | Negative values: -1.79769313486232e+308 to -4.94065645841247E-324 Positive values: 4.94065645841247E-324 to 1.79769313486232e+308 | dbl | dblAngle |
Currency | 8 bytes | -922,337,203,685,477.5808 to 922,337,203,685,477.5807 | cur | curTotalCost |
Non-numeric Data Types
Type | Size | Range of Values | Prefix | Example Variable Name |
String | Length of string | 1 to 65,400 characters (fixed length) | str | strName |
String | Length + 10 bytes | 0 to 2 billion characters (variable length) | str | strHTML |
Date | 8 bytes | January 1, 100 to December 31, 9999 | dtm | dtmBirth |
Boolean | 2 bytes | True or False | bln | blnToggle |
Object | 4 bytes | Any embedded object | obj | objCurrent |
Variant | 16 bytes | Any value as large as Double (numeric) | vnt | vntNumber |
Variant | Length+22 bytes | Same as variable-length string (text) | vnt | vntName |