CInt

This function converts an expression to a Variant of subtype Integer.

Syntax

CInt(expression)

Parameters

expression
Any valid expression.

Return Values

Returns a Variant of subtype Integer.

Remarks

Use CInt to force integer arithmetic in cases where using expression directly would result in a type mismatch or other error.

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

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