CDEC |
CDEC(expression) |
Returns the expression converted to a decimal variant-subtype (Variant). |
expression | The expression to evaluate and convert to a decimal. |
REMARKS |
* The Decimal data type is a sub type of the Variant data type. * The "expression" can be any number between -7.9 E+28 and +7.9 E+28. * If "expression" cannot be converted to a number you will get a type mismatch error. * This function always returns a Variant whose value has been converted to a Decimal subtype. * There does not actually exist a Decimal data type although it is possible to have a Variant data type, whose subtype is Decimal. * An overflow error will occur if the value is out of range. * You can use the CDATE function to return an expression converted to Date data type. * You can use the CDBL function to return an expression converted to an Double data type. * You can use the CINT function to return an expression converted to an Integer 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 CDec(15.75) '= 15.75
Debug.Print CDec(15) '= 15
Debug.Print CDec(8E+30) '= "Overflow error"
Debug.Print CDec("-100") '= -100
Debug.Print CDec("100-") '= -100
Dim decNumber As Variant
Dim lValue As Long
lValue = 12.75
decNumber = CDec(lValue)
Debug.Print decNumber
Debug.Print TypeName(decNumber) '= "Decimal"
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top