VBS TUTORIAL: function-CLNG function _vbs

Source: Internet
Author: User

CLng function

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

CLng(expression)

The expression parameter is any valid expression.

Description

Typically, you can use subtype data conversion functions to write code to show that the results of certain operations should be expressed as a specific data type, not as a default data type. For example, in the case of currency operations, single-precision, or double-precision arithmetic operations, the CInt or CLng functions are used to force integer operations.

The CLng function is used for internationally recognized format conversions from other data types to Long subtypes. For example, the recognition of the decimal separator and the thousand separator depends on the locale of the system.

If the expression value is not within the allowable range of a long subtype, an error occurs.

The following example uses the CLng function to convert a value to Long:

is a double value. CLng(MyVal1)  ' MyLong1 25427 . CLng(MyVal2)   contains  .

Note that CLng differs from the Fix and Int functions in removing decimal parts, but by rounding. When the decimal part is exactly equal to 0.5, the CLng function always rounds it to the even number closest to it. For example, 0.5 rounded to 0, and 1.5 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.