VBS Tutorial: function-CLng Function

Source: Internet
Author: User

CLng Function

Return expression, which has been convertedLongChild typeVariant.

CLng(expression)

ExpressionThe parameter is any valid expression.

Description

Generally, you can use the subtype Data Conversion Function to write code to show that the results of some operations should be expressed as specific data types rather than the default data types. For example, in the case of currency operations, single-precision or double-precision arithmetic operationsCIntOrCLngThe function forces integer operations.

CLngFunction is usedLongSub-types of internationally recognized format conversion. For example, the identification of the decimal separator and the thousands separator depends on the system's region settings.

IfExpressionIf the value is not within the permitted range of the Long subtype, an error occurs.

The following example usesCLngThe function converts the value to Long:

Dim MyVal1, MyVal2, MyLong1, MyLong2MyVal1 = 25427.45: MyVal2 = 25427.55       ' MyVal1, MyVal2 Is a double precision value.MyLong1 = CLng(MyVal1)          ' MyLong1 25427.MyLong2 = CLng(MyVal2)           ' MyLong2 Include 25428 .

Note CLngDifferent fromFixAndIntThe function deletes the decimal part, but returns the rounded value. When the decimal part is equal to 0.5,CLngThe function always rounds the number to an even number closest to the 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.