CINT |
CINT(expression) |
Returns the expression converted to an integer data type (Integer). |
expression | The expression to evaluate and convert to an integer. |
REMARKS |
* 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 function to return an expression converted to a Double data type. * You can use the CLNG function to return an expression converted to a Long data type. * You can use the CSNG function 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 learn.microsoft.com |
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"
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top