FIX |
FIX(number) |
Returns the integer portion of a number (data type). |
number | The number (data type). |
REMARKS |
* The fractional/decimal part of the number is removed. * This function is identical to the INT function for positive numbers. * This function truncates without rounding. * The value returned has the same data type as the value passed in. * If "number" is Null, Null is returned. * If "number" < 0, then the first negative integer greater than or equal to "number" is returned. * The results from this function are equivalent to : Sgn(number) * Int(Abs(number)). * You can use the INT function to return the number rounded down to the nearest integer. * You can use the ROUND function to return a number rounded to a given number of decimal places. * The equivalent .NET function is [[Microsoft.VisualBasic.Conversion.Fix]] * For the Microsoft documentation refer to learn.microsoft.com |
Debug.Print Fix(-8.9) '= -8
Debug.Print Fix(-8.4) '= -8
Debug.Print Fix(-8.1) '= -8
Debug.Print Fix(-7.9) '= -7
Debug.Print Fix(-1.9) '= -1
Debug.Print Fix(-1.1) '= -1
Debug.Print Fix(-0.1) '= -0
Debug.Print Fix(0.2) '= 0
Debug.Print Fix(0.5) '= 0
Debug.Print Fix(0.6) '= 0
Debug.Print Fix(0.9) '= 0
Debug.Print Fix(1.1) '= 1
Debug.Print Fix(1.5) '= 1
Debug.Print Fix(12.01) '= 12
Debug.Print Fix(12.34) '= 12
Debug.Print Fix(12.99) '= 12
Dim iInteger As Integer
iInteger = 20
Debug.Print TypeName(Fix(iInteger)) '= Integer
Dim lLong As Long
lLong = 20.5
Debug.Print TypeName(Fix(lLong)) '= Long
Dim dbDouble As Double
dbDouble = 20.5
Debug.Print TypeName(Fix(dbDouble)) '= Double
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top