VBScript CInt Function

Definition and Usage

The CInt function can convert an expression to an integer (Integer) type.

Note:The value must be a number between -32768 and 32767.

Note:CInt is different from the Fix and Int functions in that it removes the decimal part of the number by rounding. When the decimal part is exactly 0.5, CInt always rounds it up to the nearest even number. For example, 0.5 rounds up to 0, and 1.5 rounds up to 2.

Syntax

CInt(expression)
Parameter Description
expression Required. Any valid expression.

Instance

Example 1

dim a
a=134.345
document.write(CInt(a))

Output:

134

Example 2

dim a
a=-30000.24
document.write(CInt(a))

Output:

-30000