# CLng
{: .no_toc }

Coerces an expression to a **Long**.

Syntax: **CLng(** *expression* **)**

*expression*
: *required* Any valid string or numeric expression in the range `-2,147,483,648` to `2,147,483,647`. Fractions are rounded.

The return type is **Long**.

When the fractional part is exactly `0.5`, **CLng** always rounds it to the nearest even number. For example, `0.5` rounds to `0`, and `1.5` rounds to `2`. **CLng** differs from the [**Fix**](/tB/Modules/Conversion/Fix.md) and [**Int**](/tB/Modules/Conversion/Int.md) functions, which truncate, rather than round, the fractional part of a number.

```tb check_build check_run
Dim Half As Double, TwoAndAHalf As Double, MinusHalf As Double
Half = 0.5: TwoAndAHalf = 2.5: MinusHalf = -0.5
Debug.Print CLng(Half)          ' 0
Debug.Print CLng(TwoAndAHalf)   ' 2
Debug.Print CLng(MinusHalf)     ' 0
```

### Common Errors

| Error | When |
|---|---|
| [6 (`&H6`)](/Reference/Run-time-Errors.md#6), *Overflow* | *expression* rounds to a number less than -2,147,483,648 or greater than 2,147,483,647 |
| [13 (`&HD`)](/Reference/Run-time-Errors.md#13), *Type mismatch* | *expression* is a string that does not hold a number (a zero-length string included) |
| [94 (`&H5E`)](/Reference/Run-time-Errors.md#94), *Invalid use of Null* | *expression* is **Null** |

### Example

This example uses the **CLng** function to convert values to a **Long**.

```tb check_build
Dim MyVal1, MyVal2, MyLong1, MyLong2
MyVal1 = 25427.45: MyVal2 = 25427.55     ' MyVal1, MyVal2 are Doubles.
MyLong1 = CLng(MyVal1)                   ' MyLong1 contains 25427.
MyLong2 = CLng(MyVal2)                   ' MyLong2 contains 25428.
```

### See Also

- [CBool](/tB/Modules/Conversion/CBool.md), [CByte](/tB/Modules/Conversion/CByte.md), [CInt](/tB/Modules/Conversion/CInt.md), [CLngLng](/tB/Modules/Conversion/CLngLng.md), [CLngPtr](/tB/Modules/Conversion/CLngPtr.md), [CSng](/tB/Modules/Conversion/CSng.md), [CStr](/tB/Modules/Conversion/CStr.md), [CVar](/tB/Modules/Conversion/CVar.md) functions
- [Fix](/tB/Modules/Conversion/Fix.md), [Int](/tB/Modules/Conversion/Int.md) functions
