Format$

String = Format$ ( Expression [ , Format ] )

Converts an expression to a string by using a format that depends on the type of the expression. Format can be a predefined format (an integer constant) or a user-defined format (a string that depicts the format).

This function uses localization information to format dates, times and numbers.

See Predefined constants for a list of predefined formats. If Format is not specified, gb.Standard is used.

A user-defined number format is described by the following characters :

A user-defined date format is described by the following characters :

User-defined numeric format examples :

PRINT Format$(Pi, "-#.###")
=> 3.142

PRINT Format$(Pi, "+0#.###0")
=> +03.1416

PRINT Format$(Pi / 10, "###.# %")
=> 31.4 %

PRINT Format$(-11 ^ 11, "#.##E##")
=> -2.85E+11

User-defined date and time format examples :

PRINT Format$(Now, "mm/dd/yyyy hh:mm:ss")
=> 04/15/2002 09:05:36

PRINT Format$(Now, "m/d/yy h:m:s")
=> 4/15/02 9:5:36

PRINT Format$(Now, "ddd dd mmm yyyy")
=> Mon Apr 15 2002

PRINT Format$(Now, "dddd dd mmmm yyyy")
=> Monday April 15 2002


Referenced by :