¡¡
The Format function is a very powerful formatting function which can display the numeric values in various forms. There are two types of Format function, one of them is the built-in or predefined format while another one can be defined by the users.
(i) The format of the predefined Format function is
Format (n, ¡°style argument¡±)
where n is a number and the list of style arguments is given in Table
|
Style argument |
Explanation |
Example |
|
General Number |
To display the number without having separators between thousands. |
Format(8972.234, ¡°General Number¡±)=8972.234 |
|
Fixed |
To display the number without having separators between thousands and rounds it up to two decimal places. |
Format(8972.2, ¡°Fixed¡±)=8972.23 |
|
Standard |
To display the number with separators or separators between thousands and rounds it up to two decimal places. |
Format(6648972.265, ¡°Standard¡±)= 6,648,972.27 |
|
Currency |
To display the number with the dollar sign in front, has separators between thousands as well as rounding it up to two decimal places. |
Format(6648972.265, ¡°Currency¡±)= $6,648,972.27 |
|
Percent |
Converts the number to the percentage form and displays a % sign and rounds it up to two decimal places. |
Format(0.56324, ¡°Percent¡±)=56.32 % |
Example 13.4
Private Sub Form_Activate()
Print Format (8972.234, "General Number")
Print Format (8972.2, "Fixed")
Print Format (6648972.265, "Standard")
Print Format (6648972.265, "Currency")
Print Format (0.56324, "Percent")
End Sub
THe Output is as follows:

¡¡
¡¡