FORMATCURRENCY |
FORMATCURRENCY(expression [,numdigitsafter] [,includeleadingdigit] [,negativeuseparens] [,groupdigits]) |
Returns the expression formatted as a currency value (String). |
expression | The expression to be formatted. |
numdigitsafter | (Optional) The number -1 to 255 that specifies the number of places to the right of the decimal place (Regional) |
includeleadingdigit | (Optional) A vbTriState constant specifying if to include leading zeros (Integer): -1 = vbTrue 0 = vbFalse 1 = vbUseDefault (Default) |
negativeuseparens | (Optional) A vbTriState constant specifying how to display negative numbers (Integer): -1 = vbTrue 0 = vbFalse 1 = vbUseDefault (Default) |
groupdigits | (Optional) A vbTriState constant specifying if numbers are grouped (Integer): -1 = vbTrue 0 = vbFalse 1 = vbUseDefault (Default) |
REMARKS |
* The currency symbol used corresponds to that defined in the system control panel. * The position of the currency symbol relative to the currency value is determined by the system's regional settings. * If "numdigitsafter" is left blank, then -1 is used. * If "numdigitsafter" = -1, then Regional Settings are used. Control Panel, Region, Additional Settings, Currency Tab, No. of digits after decimal. * If "numdigitsafter" > 255, then a run-time error occurs. * The default number of decimal places is usually 2. * If "includeleadingdigit" is left blank, then vbUseDefault is used. * If "includeleadingdigit" = vbUseDefault, then Regional Settings are used. Additional Settings, Numbers Tab, Display leading zeros. * If "negativeuseparens" is left blank, then vbUseDefault is used. * If "negativeuseparens" = vbUseDefault, then Regional Settings are used. Additional Settings, Currency Tab, Negative currency format. * If "groupdigits" is left blank, then vbUseDefault is used. * If "groupdigits" = vbUseDefault, then Regional Settings are used. Additional Settings, Currency Tab, Digit grouping. * You can use the FORMAT function to return a text string of a number or date in a particular format. * You can use the FORMATDATETIME function to return an expression formatted as a date or time. * You can use the FORMATNUMBER function to return an expression formatted as a number. * You can use the FORMATPERCENT function to return an expression formatted as a percentage. * The equivalent .NET function is [[Microsoft.VisualBasic.Strings.FormatCurrency]] * For the Microsoft documentation refer to learn.microsoft.com |
Debug.Print FormatCurrency(200) '= £200.00
Debug.Print FormatCurrency(200, 3) '= £200.000
Debug.Print FormatCurrency(0.56, 3, vbFalse) '= £.560
Debug.Print FormatCurrency(0.56, 3, vbTrue) '= £0.560
Debug.Print FormatCurrency(-0.56, , , vbTrue) '= (£0.56)
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top