Custom Numeric Format Specifiers


Custom numeric format specifiers describe how a number should be formatted. The following table lists characters that you can use to build custom numeric formats.

Open table as spreadsheet

Specifier

Meaning

0

A digit or zero. If the number doesn’t have a digit in this position, the specifier adds a 0. The value 12 with the specifier 000.00 produces 012.00.

#

A digit. If the number doesn’t have a digit in this position, nothing is printed.

,

If used between two digits (either 0 or #), adds thousands separators to the result. The value 1234567 with the specifier #,# produces 1,234,567.

,

If used immediately to the left of the decimal point, the number is divided by 1000 for each comma. The value 1234567 with the specifier #,#,. produces 1,234.

%

Multiplies the number by 100 and inserts the % symbol where it appears in the specifier. The value 0.123 with the specifier .00% produces 12.30%.

E0 or e0

Displays the number in scientific notation inserting an E or e between the number and its exponent. Use # and 0 to format the number before the exponent. The number of 0s after the E determines the number of digits in the exponent. If you place a + sign between the E and 0, the result’s exponent includes a + or – sign. If you omit the + sign, the exponent only includes a sign if it is negative. The value 1234.5678 with the specifier 00.000E+000 produces 12.346E+002.

\

Displays the following character literally without interpreting it. Use \\ to display the \ character. The value 12 with the specifier #\% produces 12%, while the same value with the specifier #% produces 1200%.

'ABC’ or “ABC”

Displays the characters in the quotes literally. The value 12 with the specifier #’%’ (single quotes around the % symbol) produces 12%.




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net