Saturday, May 7, 2011

Data Types more (name formats)


Visual Basic provides several standard formats to use with the Format function. Instead of designating symbols in the format argument, you specify these formats by name in the format argument of the Format function. Always enclose the format name in double quotation marks ("").

The following table lists the format names you can use.


Named format
Description
General Number
Displays number with no thousand separator.
Currency
Displays number with thousand separator, if appropriate; display two digits to the right of the decimal separator. Output is based on user's system settings.
Fixed
Displays at least one digit to the left and two digits to the right of the decimal separator.
Standard
Displays number with thousand separator, at least one digit to the left and two digits to the righseparator.
Percent
Multiplies the value by 100 with a percent sign at the end.
Scientific
Uses standard scientific notation.
General Date
Shows date and time if expression contains both. If expression is only a date or a time, the missing information is not displayed. Date display is determined by user's system settings.
Long Date
Uses the Long Date format specified
by user's system settings.
Medium Date
Uses the dd-mmm-yy format (for example, 03-Apr-93). Date display is determined by user's system settings.
Short Date
Uses the Short Date format specified by user's system settings.
Long Time
Displays a time using user's system's long-time format; includes hours, minutes, seconds.
Medium Time
Shows the hour, minute, and "AM" or "PM" using the "hh:mm AM/PM" format.
Short Time
Shows the hour and minute using the hh:mm format.
Yes/No
Any nonzero numeric value (usually –1) is Yes. Zero is No.
True/False
Any nonzero numeric value (usually –1) is True. Zero is False.
On/Off
Any nonzero numeric value (usually –1) is On. Zero is Off.


The Format function supports many other special characters, such as the percentage placeholder and exponents.

.

No comments:

Post a Comment