In the previous lesson we learned about variables. In this lesson we will build upon the knowledge we gained in the previous lesson and learn some advanced stuff about VBScript variables.
VBScript is a loosely typed programming language. Being a loosely typed programming language, VBScript has only one data type called a Variant. It is a special kind of data type, having the capability to store different kinds of information, depending on how it is used.
A variant can contain a numeric value or it can also contain string information.
A variant behaves as a number when we use it in a numeric context and as a string when we use it in a string context.
Beyond the simple numeric or string classifications, we can further classify variants on the basis of the information they contain. For example, we can have numeric information that represents a date or a time.
We have a rich variety of numeric information ranging in size from Boolean values to huge floating-point numbers. These different categories of information are, sometimes, called subtypes of the variant data type. Most of the time, we just put the kind of data we want in a variant, and the variant behaves in a way that is most appropriate for the data it contains.
For the sake of completeness, we have summarized the subtypes of data that a variant can contain in the following table:
||Variant is uninitialized. Value is 0 for numeric variables or a zero-length string ("") for string variables.
||Variant intentionally contains no valid data.
||Contains either True or False.
||Contains integer in the range 0 to 255.
||Contains integer in the range -32,768 to 32,767.
||-922,337,203,685,477.5808 to 922,337,203,685,477.5807.
||Contains integer in the range -2,147,483,648 to 2,147,483,647.
||Contains a single-precision, floating-point number in the range -3.402823E38 to -1.401298E-45 for negative values; 1.401298E-45 to 3.402823E38 for positive values.
||Contains a double-precision, floating-point number in the range -1.79769313486232E308 to -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values.
||Contains a number that represents a date between January 1, 100 to December 31, 9999.
||Contains a variable-length string that can be up to approximately 2 billion characters in length.
||Contains an object.
||Contains an error number.
Next >>> Lesson No. 6: VBScript Strings