Go to: Articles List

All About Variables Part 2 : Variable SubTypes, Using and converting to them
Part 1 | Part 2 | Part 3

First I will list and explain all of the variable subtypes, then I will go through how to convert to them.

Variable Subtypes
Subtype Acceptable Range
Byte 0-255
Integer -32,768 to 32,767
Long -2,147,483,648 to 2,147,483,647
Single -3.402823E38 to
-1.401298E-45 for negative values;
1.401298E-45 to 3.402823E38 for positive values
Double -1.79769313486232E308 to
-4.94065645841247E-324 for negative values;
4.94065645841247E-324 to
1.79769313486232E308 for positive values
Currency -922,337,203,685,477.5808 to 922,337,203,685,477.5807
Date January 1, 100 to December 31, 9999
String Strings can range in length from 0 to 2 billion characters
Boolean True or False
Object Any Object reference

The most commonly used subtypes are string, integer, and boolean.

The following are functions you can use to convert variables to a specific subtype:

CBool Function - Converts to a Boolean Subtype
CByte Function - Converts to a Byte Subtype
CCur Function - Converts to a Currency Subtype
CDate Function - Converts to a Date Subtype
CDbl Function - Converts to a Double Subtype
CInt Function - Converts to a Int Subtype
CSng Function - Converts to a Single Subtype
CStr Function - Converts to a String Subtype

All of these functions take one parameter, a variable, and return a variable of the requested subtype. To convert one variable to a particular subtype use the following syntax:

var1 = CStr(var1)