Format User Defined Number
Description
The following number formats may be used with the Format function. Number formats may be combined to create the user defined number format. User defined number formats may not be combined with other user defined formats or predefined formats.
User defined number formats can contain up to four sections separated by ';':
- form - format for non-negative expr, '-'format for negative expr, empty and null expr return ""
- form;negform - negform: format for negative expr
- form;negform;zeroform - zeroform: format for zero expr
- form;negform;zeroform;nullform - nullform: format for null expr
Parameters |
Description |
# |
digit, don't include leading/trailing zero digits (all the digits left of decimal point are returned) |
0 |
digit, include leading/trailing zero digits |
. |
decimal, insert localized decimal point |
, |
thousands, insert localized thousand separator every 3 digits |
% |
percent, insert %, multiply expr by 100 prior to formatting |
: |
insert localized time separator |
/ |
insert localized date separator |
E+ e+ E- e- |
use exponential notation, insert E (or e) and the signed exponent |
- + $ ( ) space |
insert literal char |
\c |
insert character c |
"text" |
insert literal text |
Example
Sub Main
Debug.Print Format$(2.145,"#.00") ' 2.15
End Sub