"Variant" - Data Type and Subtypes
This section provides a quick introduction of VBScript data type, Variant, a list of subtypes: byte, integer, long, single, double, currency, string, Boolean, date, object, error, empty, and null.
Interestingly, VBScript has only one data type called "Variant",
which can be used store different kinds of data depending on
how it is used. This tells us that VBScript is a loosely typed,
or dynamically typed, language.
Even every piece of data in VBScript is considered as the same data type, "Variant",
it can be grouped into a specific category of data based on its value.
These categories of data are called subtypes.
VBScript supports the following 13 data subtypes:
- Byte: Using 1 byte to express integers ranging from 0 to 255.
- Integer: Using 2 bytes to express signed integers ranging from -32,768 to 32,767.
- Long: Using 4 bytes to express signed integers ranging from -2,147,483,648 to 2,147,483,647.
- Single: Using 4 bytes to express real numbers in floating-point format ranging
from -3.402823e38 to -1.401298e-45 for negative values,
and from 1.401298e-45 to 3.402823e38 for positive value.
- Double: Using 8 bytes to express real numbers in floating-point format ranging
from -1.79769313486232e308 to -4.94065645841247e-324 for negative values,
and from 4.94065645841247e-324 to 1.79769313486232e308 for positive values.
- Currency: Using 8 bytes to express real numbers in decimal format ranging from -922,337,293,685,477.5808 to
- String: Using 1 byte per character to express a sequence of characters up to approximately 2 billion characters.
- Boolean: Using 2 bytes to express two Boolean values: True and False.
- Date: Using 8 bytes to express dates ranging from January 1, 100 to December 31, 9999.
- Empty: A special subtype to represent a variable that has not been assigned with any value yet.
- Null: A special subtype to represent a variable assigned with a null value.
- Object: A special subtype to represent a reference to an object.
- Error: A special subtype to represent an error number.
See next sections to learn how to use Variant and subtypes.
Table of Contents
About This Book
Introduction of VBScript - Visual Basic Scripting Edition
►Variant Data Type, Subtypes, and Literals
►"Variant" - Data Type and Subtypes
Data Literal Examples
String Data Literals
Date and Time Data Literals
Numeric Comparison Operations and Logical Operations
String Operations - Concatenation and Comparison
Variable Declaration and Assignment Statement
Expression and Order of Operation Precedence
Statement Syntax and Statement Types
Array Data Type and Related Statements
Array References and Array Assignment Statements
Conditional Statements - "If ... Then" and "Select Case"
Loop Statements - "For", "While", and "Do"
"Function" and "Sub" Procedures
Inspecting Variables Received in Procedures
Error Handling Flag and the "Err" Object
Regular Expression Pattern Match and Replacement
scrrun.dll - Scripting Runtime DLL Library
Creating Your Own Classes
IE Web Browser Supporting VBScript
IIS ASP Server Supporting VBScript
WSH (Windows Script Host)
PDF Printing Version