11 out of 20 rated this helpful - Rate this topic

# CInt Function

Updated: August 2009

Returns an expression that has been converted to a Variant of subtype Integer.

```
CInt(expression)
```

The expression argument is any valid expression.

Use the CInt function to provide conversions from any other data type to an Integer subtype. For example, CInt forces integer arithmetic when currency, single-precision, or double-precision arithmetic would normally occur.

The CInt function uses the locale setting of your system to determine how to perform conversions. Different decimal separators are properly recognized depending on the locale setting, as are different thousand separators.

If expression lies outside the acceptable range for the Integer subtype, an error occurs.

The following example uses the CInt function to convert a value to an integer.

```Dim MyDouble, MyInt
MyDouble = 2345.5678     ' MyDouble is a Double.
MyInt = CInt(MyDouble)   ' MyInt contains 2346.
```
Note:

When the fractional part of a value is exactly 0.5, the CInt function rounds to the closest even number. For example, 0.5 rounds to 0, 1.5 rounds to 2, and 3.5 rounds to 4. The purpose of rounding to the closest even number is to compensate for a bias that could accumulate when many numbers are added together.

CInt differs from the Fix and Int functions, which truncate, rather than round, the fractional part of a number.

Date

History

Reason

August 2009

Modified remarks.

Customer feedback.