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 E28 and +7.9 E28 * 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. * For a full list of conversion functions refer to the Explicit Conversion page. * For the Microsoft documentation refer to docs.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 Decimal
Dim lValue As Long
lValue = 12.75
decNumber = CDec(lValue)
Debug.Pring decNumber
Debug.Print TypeName(decNumber) '= "Decimal"
© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited Top