ASP function data type conversion function forced conversion

Source: Internet
Author: User

Each function can forcibly convert an expression to a specific data type.

Syntax

Cbool (expression)

Cbyte (expression)

Ccur (expression)

Cdate (expression)

Cdbl (expression)

Cdec (expression)

CINT (expression)

Clng (expression)

Csng (expression)

CSTR (expression)

CVaR (expression)

CSTR (expression)

The required expression parameter can be any string or numeric expression.

Return type

The function name determines the return type, as shown below:

Function return type expression parameter range

Cbool Boolean any valid string or numeric expression.

Cbyte byte 0 to 255.

Ccur currency-922,337,203,685,477.5808 to 922,337,203,685,477.5807.

Cdate any valid date expression.

Cdbl double negative number from-1.79769313486232e308 to-4.94065645841247e-324; positive

The number ranges from 4.94065645841247e-324 to 1.79769313486232e308.

Cdec decimal zero ratio value, that is, no decimal point

+ //-79,228,162,514,264,337,593,543,950,335. For the 28-digit decimal value, the range is

Is

+/-7.9228162514264337593543950335; the minimum possible non-zero value is 0.00000000000000

00000000000001.

CINT integer-32,768 to 32,767, rounded to the decimal part.

Clng long-2,147,483,648 to 2,147,483,647, rounded to the decimal part.

The negative csng single number is-3.402823e38 to-1.401298e-45, and the positive number is 1.401298e-45.

To 3.402823e38.

CSTR string returns CSTR based on the expression parameter.

If CVaR variant is a value, the range is the same as that of double. If not, the range is the same as that of stri.

Ng is the same.

Description

If the expression passed to the function exceeds the conversion target data type range, an error occurs. Generally, you can use a data type conversion function during encoding to indicate that the result of some operations should be represented as a specific data type, rather than the default data type. For example, when single-precision, double-precision, or integer operations occur, ccur is used to force the currency operation.

The data type conversion function should be used to replace Val, so that the international version of data conversion can be converted from one data type to another. For example, when ccur is used, different decimal separator, kilobytes separator, and various currency options are properly identified based on the country settings of the system.

When the decimal part is 0.5, The CINT and clng functions convert it to the closest even value. For example, 0.5 is converted to 0, and 1.5 is converted to 2. The CINT and clng functions are different from the fix and INT functions. The FIX and INT functions truncate the fractional part rather than rounding it. And the fix and INT functions always return the same value as the input data type.

Use the isdate function to determine whether a date can be converted to a date or a time. Cdate can be used to identify date text and time text, as well as numbers falling into the acceptable date range. When a number is converted to a date, the integer part is converted to a date, and the decimal part is converted to the time from midnight.

Cdate determines the date format based on the country settings on the system. If the format provided is an unrecognized date setting, the order of the year, month, and day cannot be correctly determined. In addition, the long date format cannot be recognized if it contains a string of weeks.

The cvdate function also provides compatibility with earlier Visual Basic versions. The syntax of the cvdate function is exactly the same as that of the cdate function. However, cvdate returns a variant with a subtype of date instead of the actual date type. Cvdate is no longer needed because the current date type already exists. Convert an expression to date and assign a value to variant, which can achieve the same effect. You can also use this technique to convert other real data types into equal variant subtypes.

Note that the cdec function cannot return an independent data type, but always returns a variant. Its value has been converted to a decimal subtype. Cbool (expression)

Related Article

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.