To appropriately display a value, the Visual
Basic language provides a function named Format. This function can be used for
different types of values The most basic technique consists of passing it an
expression that holds the value to display. The syntax of this function is:

As mentioned above, this function can be used in various
scenarios. The simplest way to use this function is to pass it a number, a
string, or a date/time). The function would then produce that number.

Besides the Format() function, the Visual Basic
language provides some additional functions we will review below.

Formatting a Percentage Value

A percentage of a number represents its rate on a scale,
usually of 100 (or more). The number is expressed using digits accompanied by
the % sign. Besides the Format() function, to support percent values, the Visual Basic language provides a function named FormatPercent.
Its syntax is:

Only the first argument is required and it is the number
that needs to be formatted. When calling this function, pay attention to the
number you provide as argument. If the number represents a percentage value as a
fraction of 0 to 1, make sure you provide it as such. An example would be 0.25.
In this case, the Visual Basic interpreter would multiply the value by 100 to
give the result. Here is an example:

On the other hand, if you pass the value in the hundreds,
the interpreter would still multiply it by 100. Although it is not impossible to
get a percentage value in the hundreds or thousands, you should make sure that's
the type of value you mean to get.

Besides the FormatPercent() function, to format a
number to its percentage equivalent, you can call the Format() function
and pass the second argument as "Percent", "p", or
"P". Here is an example: