Introduction to VB6 Variable Types

By | 2009-12-30

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

TypeSizeRange of ValuesPrefixExample Variable Name
Byte1 byte0 to 255bytbytFirstChar
Integer2 bytes-32,768 to 32,767intintCount
Long4 bytes-2,147,483,648 to 2,147,483,648lnglngHwnd
Single4 bytesNegative values: -3.402823E+38 to -1.401298E-45
Positive values: 1.401298E-45 to 3.402823E+38
sngsngPi
Double8 bytesNegative values: -1.79769313486232e+308 to -4.94065645841247E-324
Positive values: 4.94065645841247E-324 to 1.79769313486232e+308
dbldblAngle
Currency8 bytes-922,337,203,685,477.5808 to 922,337,203,685,477.5807curcurTotalCost

Non-numeric Data Types

TypeSizeRange of ValuesPrefixExample Variable Name
StringLength of string1 to 65,400 characters (fixed length)strstrName
StringLength + 10 bytes0 to 2 billion characters (variable length)strstrHTML
Date8 bytesJanuary 1, 100 to December 31, 9999dtmdtmBirth
Boolean2 bytesTrue or FalseblnblnToggle
Object4 bytesAny embedded objectobjobjCurrent
Variant16 bytesAny value as large as Double (numeric)vntvntNumber
VariantLength+22 bytesSame as variable-length string (text)vntvntName
Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.