Saturday, May 7, 2011

Data Types more (Formatting Numbers, Dates, and Times)

 .
Visual Basic provides great flexibility in displaying number formats, as well as date and time formats. You can easily display international formats for numbers, dates, and times.

The Format function converts the numeric value to a text string and gives you control over the string’s appearance. For example, you can specify the number of decimal places, leading or trailing zeros, and currency formats. The syntax is:

Format(expression[, format[, firstdayofweek[, firstweekofyear]]])
The expression argument specifies a number to convert, and the format argument is a string made up of symbols that shows how to format the number. The most commonly used symbols are listed in the table below.

Symbol
Description
0
Digit placeholder; prints a trailing or a leading zero in this position, if appropriate.
#
Digit placeholder; never prints trailing or leading zeros.
.
Decimal placeholder.
,
Thousands separator.
– + $ ( ) space
Literal character; characters are displayed exactly as typed into the format string.

The firstdayofweek argument is a constant that specifies the first day of the week; the firstweekofyear argument is a constant that specifies the first week of the year. Both arguments are optional. For more information about these constants, 

.
.

No comments:

Post a Comment