Returns the expression converted to an integer data type (Integer).

expressionThe expression to evaluate and convert to an integer.

* The Integer data type is a Value data type.
* The "expression" can be any value between -32,768 and 32,767.
* If "expression" is outside the range of the data type being converted to, an error occurs.
* If "expression" includes any fractions or decimals these are rounded.
* Any fractional parts greater than 0.5 are rounded up.
* Any fractional parts less than 0.5 are rounded down.
* Any fractional parts equal to 0.5 are rounded to the nearest even number.
* This type of rounding is called banker's rounding and its purpose is to compensate for a bias that could accumulate when adding a lot of 0.5 fractions.
* VBAs hexadecimal notation symbol is "&H"
* You can use the CDBL to return an expression converted to a double data type.
* You can use the CLNG to return an expression converted to a long data type.
* You can use the CSNG to return an expression converted to a single data type.
* For a full list of conversion functions refer to the Explicit Conversion page.
* For the Microsoft documentation refer to

Debug.Print CInt(-1.1)     '= -2  
Debug.Print CInt(-1.9) '= -2
Debug.Print CInt(0.2) '= 0
Debug.Print CInt(0.5) '= 0
Debug.Print CInt(0.6) '= 1
Debug.Print CInt(0.9) '= 1
Debug.Print CInt(1.1) '= 1
Debug.Print CInt(1.5) '= 2
Debug.Print CInt(2.5) '= 2
Debug.Print CInt(2.6) '= 3
Debug.Print CInt(11.5) '= 12
Debug.Print CInt(12.5) '= 12
Debug.Print CInt(12.6) '= 13
Debug.Print CInt(12.9) '= 13
Debug.Print CInt("&H75FF") '= 30207
Debug.Print CInt("&H754") '= 1876

Dim iNumber As Integer
Dim lValue As Long
lValue = 12.75
iNumber = CInt(lValue)
Debug.Print iNumber
Debug.Print TypeName(iNumber) '"Integer"

© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited Top