In this chapter, we’ll discuss VBScript’s rather unusual support for a single data type before turning to variables and constants in VBScript.
Unlike Visual Basic and Visual Basic for Applications, VBScript has only a single data type, called a variant. A variant is a very special data type, since it can contain many different types of data and can automatically select the most appropriate data type for the particular context in which it is being used. A simplified view of a variant is that it can hold both string data (characters) and numerical data as well as other data, such as dates, Booleans, and objects. Internally it is much more complex, which permits it to hold a wide range of different numeric types.
While the only data type recognized by VBScript is the variant, any item of variant data belongs to a particular type. Let’s look at the range of types — or the different types of data — that a variant can hold:
Empty is a type that consists of a single value,
Empty, that is
automatically assigned to new variables when you declare them,
but before you explicitly assign a value to them. For
instance, in the code fragment:
Dim var1, var2 var2 = 0
the type of
var1 is Empty,
var2 is only Empty for the
brief period of time between the execution of the
Dim statement on the first line
(which declares a variable; it is discussed later in this
chapter in Section ...