Variable types introduction

Posted On 2009-12-30 by FortyPoundHead
Tags: Tutorial VB6 Miscellaneous General 
Views: 2036

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

About the Author

FortyPoundHead has posted a total of 1974 articles.


Comments On This Post

No comments on this post yet!

Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.

Your IP address is:

Before you can post, you need to prove you are human. If you log in, this test goes away.

Recent Forum Posts

Advanced search added
dwirch posted on September 23, 2017 at about 13:44 in Site News

Job Spammer: Gaurav Mehta - AgreeYa Solutions
dwirch posted on September 22, 2017 at about 10:35 in Spammers

Job Spammer: Prutha Siri - Javelin Systems
dwirch posted on September 10, 2017 at about 6:15 in Spammers

New security implemented
dwirch posted on September 7, 2017 at about 7:16 in Site News

Malicious IP Checker Companion Tool
dwirch posted on August 12, 2017 at about 20:24 in Site News

Job Spammer: Steve Adams
dwirch posted on August 8, 2017 at about 7:44 in Spammers