Format Function


    When you want to format data for display, either on the printer or on the screen, use the Format function.

Format ($) (ExpressionToFormat [, "FormatDescription"])

    The expression to be formatted may be numeric or string, a variable, a literal, or a property. In most cases, you will use formats for numeric data to control the number of decimal positions.

Predefined Format Names Description
Currency A dollar sign; two digits to the right of the decimal; a comma for thousands, if needed; negative numbers in parentheses.
Fixed Two digits to the right of the decimal point; displays 0 to the left of decimal if the value is less than one; no comma for thousands.
General Displays the number as it appears.
Medium Time * A 12-hour time format; uses hours and minutes and AM or PM.
On/Off Displays the word Off it the value is 0; all other values will display as On.
Percent Number multiplied by 100 with percent sign on right; two digits to the right of the decimal point.
Scientific Standard scientific notation (E notation).
Short Date Uses the system date format.
Short Time A 24-hour time format, with hours and minutes, such as 15:30.
Standard Two digits to the right of the decimal point and a  comma for thousands if necessary.
True/False Displays False if the value is 0; all other values will display as True
Yes/No Displays No if the value is 0; all other values will display as Yes
* Time and Date may be Medium, Short or Long

    Some examples:

lblTotal.Caption = Format$ (cTotalAmount, "Currency")
lblDate.Caption = Format$ (iBirthdate, "Short Date")    
Print Format$(dToday, "Short Date")                           

Custom Numeric Formats


Symbol Descrition Purpose
0 Zero placeholder Displays a digit in the position, if there is no digit, a zero will display.
# Null placeholder Displays a digit in the position, if there is no digit, nothing will display.
. Decimal point Displays the decimal point in the position.
, Thousand separator Inserts appropriate commas when the number is greater than or equal to 1,000.
& Percentage Multiplies the value by 100 and adds the percentage symbol.