Using Visual Basic Format

Using the Visual Basic format() function
The Format function converts a value to a text string and gives you control over the string's appearance. For example, you can specify the number of decimalplaces for a numeric value, leading or trailing zeros, currency formats, and portions of the date. The syntax is:
Format(expression [,format [,firstdayofweek [,firstweekofyear]]])expression
Any valid expression
A valid named or user-defined format expression
A constant that specifies the first day of the week
A constant that specifies thefirst week of the year
The firstdayofweek argument has these settings:
Constant Value Description
vbUseSystem 0 Use NLS API setting.
vbSunday 1 Sunday (default)
vbMonday 2 Monday
vbTuesday 3Tuesday
vbWednesday 4 Wednesday
vbThursday 5 Thursday
vbFriday 6 Friday
vbSaturday 7 Saturday
The firstweekofyear argument has these settings:
Constant Value Description
vbUseSystem 0 Use NLS APIsetting.
vbFirstJan1 1 Start with week in which January 1 occurs (default).
vbFirstFourDays 2 Start with the first week that has at least four days in the year.
vbFirstFullWeek 3 Start with thefirst full week of the year.
If you try to format a number without specifying format, Format provides functionality similar to the Str function, although it is internationally aware. However,positive numbers formatted as strings using Format don’t include a leading space reserved for the sign of the value; those converted using Str retain the leading space.
If you are formatting anon-localized numeric string, you should use a user-defined numeric format to ensure that you get the look you want.
If the Calendar property setting is Gregorian and format specifies date formatting, thesupplied expression must be Gregorian. If the Visual Basic Calendar property setting is Hijri, the supplied expression must be Hijri.
If the calendar is Gregorian, the meaning of format expression...
tracking img