VBS TUTORIAL: function-cint function _vbs

Source: Internet
Author: User

CInt function

Returns an expression that has been converted to a Variantof the Integer subtype.

CInt(expression)

The expression parameter is any valid expression.

Description

In general, you can use a subtype conversion function to write code to show that the results of some operations should be represented as a specific data type, not the default type. For example, in the case of currency, single-precision, or double-precision operations, you use CInt or CLng to force an integer operation.

The CInt function is used for internationally recognized format conversions from other data types to Integer subtypes. For example, the recognition of decimal separators, such as thousands, may depend on the locale of the system.

If the expression is outside the acceptable range of the Integer subtype, an error occurs.

The following example uses the CInt function to convert a value to an Integer:

Dim MyDouble, MyIntMyDouble = 2345.5678      Is  Double . CInt(MyDouble) ' MyInt contains  2346 .

Note that CInt differs from the Fix and Int functions by removing numeric decimal parts, but by rounding. When the decimal part is exactly equal to 0.5, CInt always rounded it to the nearest even number. For example, 0.5 is rounded to 0, and 1.5 is rounded to 2.

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.