NumberFormat Property
This property returns or sets a value indicating the format string for a control column.
column.NumberFormat= string
Read/Write at run time and design time.
Property applies to Column object.
By default, the NumberFormat property contains an empty string, and column data is unformatted.
For numeric data, the following predefined format names can be used:
General Number |
Display number as is, with no thousand separators. |
Currency |
Display number with thousand separator, if appropriate; display two digits to the right of the decimal separator. Note that output is based on system locale settings. |
Fixed |
Display at least one digit to the left and two digits to the right of the decimal separator. |
Standard |
Display number with thousands separator, at least one digit to the left and two digits to the right of the decimal separator. |
Percent |
Display number multiplied by 100 with a percent sign (%) appended to the right; always display two digits to the right of the decimal separator. |
Scientific |
Use standard scientific notation. |
Yes/No |
Display No if number is 0; otherwise, display Yes. |
True/False |
Display False if number is 0; otherwise, display True. |
On/Off |
Display Off if number is 0; otherwise, display On. |
For date and time data, the following predefined format names can be used:
General Date |
Display a date and/or time. For real numbers, display a date and time (for example, 4/3/93 05:34 PM); if there is no fractional part, display only a date (for example, 4/3/93); if there is no integer part, display only a time (for example, 05:34 PM). Date display is determined by your system settings. |
Long Date |
Display a date according to your system's long date format. |
Medium Date |
Display a date using the medium date format appropriate for the language version of Visual Basic. |
Short Date |
Display a date using your system's short date format. |
Long Time |
Display a time using your system's long time format: includes hours, minutes, seconds. |
Medium Time |
Display a time in 12-hour format using hours and minutes and the AM/PM designator. |
Short Time |
Display a time using the 24-hour format (for example, 17:45). |
For arbitrary data, the following predefined format name can be used:
FormatText Event |
Fire the FormatText event for the associated column. This option allows you to write your own formatting code for situations where Visual Basic's intrinsic formatting is unavailable or does not suit your needs. |
The NumberFormat property also accepts user-defined format strings. See the Microsoft Visual Basic documentation (Format function) for details.
If the NumberFormat property is set to an invalid string, cell data are displayed as #ERR#.
Note: The NumberFormat property works only in container environments that support Visual Basic formatting through OLE. If a container does not provide this support, the NumberFormat property can still be set without causing an error, but cell data will not be formatted.
However, the FormatText Event option can be used in any container environment, even if Visual Basic formatting is unavailable.
See Also