VBScript Tutorial lesson three VBScript data type _vbs

Source: Internet
Author: User
Tags numeric
What is a VBScript data type?

VBScript has only one data type, called a Variant. A Variant is a special type of data that, depending on how it is used, can contain different categories of information. Because the 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. A Variant is used as a numeric processing in a numeric context and is used as a string in the context of a string. That is, if you use data that looks like a number, VBScript assumes it is a number and handles it in a digital way. Similarly, if the data used is only a string, VBScript will be treated as a string. 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, a Variant can further differentiate between specific meanings of numeric information. For example, use numeric information to represent a date or time. When this type of data is used with other date or time data, the result is always expressed as a date or time. Of course, numeric information is varied from Boolean values to floating-point numbers. A Variant contains a numeric information type called a subtype. In most cases, you can put the data you want into a variant, and the variant will operate in the way that best applies to the data it contains.

The following table shows the data subtypes that the Variant contains:

Sub Type
Empty

An uninitialized Variant. For a numeric variable, the value is 0; for a string variable, the value is a zero-length string ("").

Null
A Variant that does not contain any valid data.

Boolean
Contains True or False.

Byte
Contains integers between 0 and 255.

Integer
Contains integers from 32,768 to 32,767.
Currency
-922,337,203,685,477.5808 to 922,337,203,685,477.5807.

Long
Contains integers from 2,147,483,648 to 2,147,483,647.

Single
Contains single-precision floating-point numbers, with a negative range from -3.402823E38 to -1.401298E-45, and a positive range from 1.401298E-45 to 3.402823E38.
Double
Contains double-precision floating-point numbers, with a negative range from -1.79769313486232E308 to -4.94065645841247E-324, and a positive range from 4.94065645841247E-324 to 1.79769313486232E308.

Date (Time)
Contains a number that represents a date ranging from January 1, 100 to A.D. December 31, 9999.
String
Contains a variable-length string with a maximum length of 2 billion characters.

Object
Contains objects.

Error
Contains the error number.

You can use conversion functions to transform subtypes of data. Alternatively, you can use the VarType function to return the Variant subtype of the data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.