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 Fix and Int functions in that it does not remove the decimal part of the number but rounds it off. When the decimal part is exactly 0.5, CInt always rounds it off to the nearest even number. For example, 0.5 is rounded off to 0, and 1.5 is rounded off 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