FormatNumber Merge Method
Usage | Parameters | Examples | Remarks
The FormatNumber merge method converts any numeric value to a specified format. Standard format types or a format structure can be specified.
Usage
FormatNumber([NumberToFormat],[Format]) |
Converts a number into a specified format |
Parameters
NumberToFormat Number
The number to be formatted.
Format Text
A format specifier describing the way the resulting number should be presented. The format can be referenced as a type with the number of decimal places or explicitly stated as a format structure. See the format options below for further details.
Examples
Example 1
Name a document including the value of the zone "Total" as a formatted number.
In this example, the result would be "Document total 1,234.00"
Example 2
Name a document including the value of the zone "Sales" as a percentage with no decimal places.
In this example, the result would be "Sales Percentage 87%"
Example 3
Name a document using the value of the zone "Total" formatted with a specific format.
In this example, the result would be "June Orders 1,234.50"
Remarks
None
Format Options
Format Types
For use when utilizing a pre-formatted numeric types.
Character |
Description |
N |
Returns a number with thousand separator, at least one digit to the left and two digits to the right of the decimal separator. eg. 123 = 123.00 |
D |
Returns a number as a string that contains the value of the number in Decimal (base 10) format. eg. &H7F = 127 |
P |
Returns a number with thousandths separator multiplied by 100 with a percent sign (%) appended to the right and separated by a single space. eg. 0.80345 = 80.35% |
C |
Returns a number with thousand separator, if appropriate; displays two digits to the right of the decimal separator. eg. 1234567 $1,234,567.00 |
N3 |
Returns a number with 3 decimal places eg. 123.000 |
D3 |
Returns a decimal with 3 decimal places 123.000 |
P4 |
Returns a percentage with 4 decimal places eg. 98.0000% |
C4 |
Returns a number in currency format with 4 decimal places eg. $123.0000 |
Format Specifiers
For use when explicitly stated the required format.
Character |
Description |
0 |
Digit placeholder. Displays a digit or a zero. If the expression has a digit in the position where the zero appears in the format string, display it; otherwise, displays a zero in that position. |
|
If the number has fewer digits than there are zeros (on either side of the decimal) in the format expression, displays leading or trailing zeros. If the number has more digits to the right of the decimal separator than there are zeros to the right of the decimal separator in the format expression, rounds the number to as many decimal places as there are zeros. If the number has more digits to the left of the decimal separator than there are zeros to the left of the decimal separator in the format expression, displays the extra digits without modification. |
(#) |
Digit placeholder. Displays a digit or nothing. If the expression has a digit in the position where the # character appears in the format string, displays it; otherwise, displays nothing in that position. |
|
This symbol works like the 0 digit placeholder, except that leading and trailing zeros aren't displayed if the number has fewer digits than there are # characters on either side of the decimal separator in the format expression. |
(.) |
Decimal placeholder. The decimal placeholder determines how many digits are displayed to the left and right of the decimal separator. If the format expression contains only # characters to the left of this symbol; numbers smaller than 1 begin with a decimal separator. To display a leading zero displayed with fractional numbers, use zero as the first digit placeholder to the left of the decimal separator. In some locales, a comma is used as the decimal separator. The actual character used as a decimal placeholder in the formatted output depends on the number format recognized by your system. Thus, you should use the period as the decimal placeholder in your formats even if you are in a locale that uses a comma as a decimal placeholder. The formatted string will appear in the format correct for the locale. |
(%) |
Percent placeholder. Multiplies the expression by 100. The percent character (%) is inserted in the position where it appears in the format string. |
(,) |
Thousand separator. The thousand separator separates thousands from hundreds within a number that has four or more places to the left of the decimal separator. Standard use of the thousand separator is specified if the format contains a thousand separator surrounded by digit placeholders (0 or #). |
|
A thousand separator immediately to the left of the decimal separator (whether or not a decimal is specified) or as the rightmost character in the string means "scale the number by dividing it by 1,000, rounding as needed." Numbers smaller than 1,000 but greater or equal to 500 are displayed as 1, and numbers smaller than 500 are displayed as 0. Two adjacent thousand separators in this position scale by a factor of 1 million, and an additional factor of 1,000 for each additional separator. |
|
Multiple separators in any position other than immediately to the left of the decimal separator or the rightmost position in the string are treated simply as specifying the use of a thousand separator. In some locales, a period is used as a thousand separator. The actual character used as the thousand separator in the formatted output depends on the Number Format recognized by your system. Thus, you should use the comma as the thousand separator in your formats even if you are in a locale that uses a period as a thousand separator. The formatted string will appear in the format correct for the locale. |
|
For example, consider the three following format strings: |
|
- "#,0.", which uses the thousands separator to format the number 100 million as the string "100,000,000". |
|
- "#0,.", which uses scaling by a factor of one thousand to format the number 100 million as the string "100000". |
|
- "#,0,.", which uses the thousands separator and scaling by one thousand to format the number 100 million as the string "100,000". |
(E-``E+``e-``e+) |
Scientific format. If the format expression contains at least one digit placeholder (0 or #) to the left of E-, E+, e-, or e+, the number is displayed in scientific format and E or e is inserted between the number and its exponent. The number of digit placeholders to the left determines the number of digits in the exponent. Use E- or e- to place a minus sign next to negative exponents. Use E+ or e+ to place a minus sign next to negative exponents and a plus sign next to positive exponents. You must also include digit placeholders to the right of this symbol to get correct formatting. |
- + $ ( ) |
Literal characters. These characters are displayed exactly as typed in the format string. To display a character other than one of those listed, precede it with a backslash (\) or enclose it in double quotation marks (" "). |
(\) |
Displays the next character in the format string. To display a character that has special meaning as a literal character, precede it with a backslash (\). The backslash itself isn't displayed. Using a backslash is the same as enclosing the next character in double quotation marks. To display a backslash, use two backslashes (\\). |