CLngLng

Coerces an expression to a LongLong.

Syntax: CLngLng( expression )

expression
required Any valid string or numeric expression in the range -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. Fractions are rounded.

The return type is LongLong.

When the fractional part is exactly 0.5, CLngLng always rounds it to the nearest even number. For example, 0.5 rounds to 0, and 1.5 rounds to 2. CLngLng differs from the Fix and Int functions, which truncate, rather than round, the fractional part of a number.

Note

Conversion functions must be used to explicitly assign LongLong to smaller integral types. Implicit conversions of LongLong to smaller integrals are not allowed.

Note

In VBA, LongLong (and therefore CLngLng) is restricted to 64-bit hosts. twinBASIC supports LongLong in both 32-bit and 64-bit modes — see Data Types.

Common Errors

Error When
6 (&H6), Overflow expression rounds to a number less than -9,223,372,036,854,775,808 or greater than 9,223,372,036,854,775,807
13 (&HD), Type mismatch expression is a string that does not hold a number (a zero-length string included)
94 (&H5E), Invalid use of Null expression is Null

Example

This example uses the CLngLng function to convert an expression to a LongLong.

Dim someValue As Variant
someValue = 9223372036854775807^
Dim longLongValue As LongLong
longLongValue = CLngLng(someValue)
MsgBox "The LongLong representation is: " & longLongValue

See Also