CLNG(expression)

Returns the expression converted to a long data type (Long).


expressionThe expression to evaluate and convert to a long.

REMARKS
* The Long data type is a Value data type.
* The "expression" can be any number between (- 2.1 E+9) and (2.1 E+9).
* If "expression" includes any fractions or decimals these are rounded.
* If "expression" is outside the range of the data type being converted to, an error occurs.
* Any fractional parts less than or equal to 0.5 are rounded to the nearest even number.
* Any fractional parts greater than 0.5 are rounded up.
* You can use the CDBL function to return an expression converted to a double data type.
* You can use the CINT function to return an expression converted to an integer data type.
* You can use the CSNG function to return an expression converted to a single data type.
* You can use the CLNGLNG function to return the expression converted to a LongLong (64 bit platform) data type.
* You can use the CLNGPTR function to return a LongPtr data type.
* For the Microsoft documentation refer to docs.microsoft.com

CLng(0.5) = 0 
CLng(0.6) = 1
CLng(1.5) = 2
CLng(2.5) = 2
CLng(2.6) = 3
CLng(2.9) = 3
CLng(3.5) = 4

Dim iCount As Integer
Dim lReturn As Long
iCount = 30.75
lReturn = CLng(iCount) = 30

CLng("1234567") = 1234567

© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited Top