VBScript tutorial lesson 3 VBScript data types


What is VBScript data type?

VBScript has only one data type, called variant. Variant is a special data type. It can contain different types of information according to the way it is used. Because variant is the only data type in VBScript, it is also the data type of the return value of all functions in VBScript.

The simplest variant can contain numeric or string information. Variant is processed as a number when used in a digital context and as a string when used in a string context. That is, if you use data that looks like a number, VBScript assumes it is a number and processes it in a manner suitable for numbers. Similarly, if the data used can only be strings, VBScript will process as strings. Of course, you can also include a number in quotation marks (“”) to make it a string.

Variant subtype

In addition to simple numbers or strings, variant can further distinguish the specific meaning of numerical information. For example, use numeric information to represent a date or time. When such data is used with other date or time data, the result is always expressed as date or time. Of course, there are many kinds of numerical information, from Boolean value to floating-point number. The types of numeric information contained in a variant are called subtypes. In most cases, you can put the required data into the variant, and the variant will operate in the way that is most suitable for the data it contains.

The following table shows the data subtypes that variant contains:


Uninitialized variant. For numeric variables, the value is 0; For string variables, the value is a zero length string (“”).

Variant that does not contain any valid data.

Contains true or false.

Contains an integer between 0 and 255.

Contains an integer between – 32768 and 32767.
-922337203685477.5808 to 922337203685477.5807.

Contains an integer between – 2147483648 and 2147483647.

Contains single precision floating-point numbers, with negative numbers ranging from -3.402823e38 to -1.401298e-45 and positive numbers ranging from 1.401298e-45 to 3.402823e38.
Contains double precision floating-point numbers, with negative numbers ranging from -1.79769313486232e308 to -4.94065645841247e-324 and positive numbers ranging from 4.94065645841247e-324 to 1.79769313486232e308.

Date (Time)
Contains a number indicating the date, ranging from January 1, A.D. 100 to December 31, A.D. 9999.
Contains variable length strings with a maximum length of 2 billion characters.

Contains objects.

Contains the error number.

You can use conversion functions to convert subtypes of data. Alternatively, you can use the vartype function to return the variant subtype of the data.

Recommended Today

Go concurrent programming (8) deep understanding of sync Once

In the previous article “week03: go concurrent programming (VII) in-depth understanding of errgroup”errgourpWhen we find the source code, we finally return iterrOnly a non nil value is guaranteed to be returned through once. This article will take a look at the use and implementation of once case Once is easy to use `func main() {` `var (` `o  sync.Once` […]