<< Click to Display Table of Contents >> Format (function) |
Format(Expression [,Format])
Returns a string consisting of the Expression parameter formatted according to the chosen formatting instructions.
The desired format is specified using the string parameter Format. You can choose from several predefined formats that are listed on the pages that follow. Additionally, more precise formatting can be achieved using user-defined formats.
If the parameter Format is empty and Expression is a number, the Format function will return the same result as the Str function, with the exception that Format does not prepend a space character to positive numbers.
For numeric formats, Expression must be a numeric expression; for string formats it must be a string.
For date/time formats, Expression must be a string with the same structure as returned by the Now function.
See also: Str, sections Numeric formats of the Format function, Date/time formats of the Format function and String formats of the format Function
Example:
Sub Main
MsgBox Format(Date, "long date")
MsgBox Format(Date, "dd.mm.yy")
End Sub