This documentation is archived and is not being maintained.

Application.FormatString Method

Office 2007
Formats the specified string or XML node according to the specified category and options parameters.

Version Information
 Version Added:  InfoPath 2003

Syntax

expression.FormatString(varInput, bstrCategory, bstrOptions)

expression   An expression that returns a Application object.

Parameters

NameRequired/OptionalData TypeDescription
varInputRequiredVariantThe string value or XML node to be formatted.
bstrCategoryRequiredStringThe string value that specifies the category used for formatting. Values include number, percentage, currency, date, time, and datetime.
bstrOptionsRequiredStringThe string value that specifies the options used for formatting. Takes the form of a case-sensitive string in the format "optionName:value".

Return Value
String

Remarks

The FormatString method can be used anywhere in your scripting code in which you need to change the format of a specified string. It must be qualified with the Application object name, and its return value must be assigned to a variable or used as an expression that requires a string value.

The following sections list the values that may be used for the

bstrCategory parameter:

NameDescription
numberUses numerical values. Valid options for this category include locale, numDigits, leadingZero, grouping, decimalSep, thousandSep, and negativeOrder.
percentageUses percentage values. Valid options for this category include locale, numDigits, leadingZero, grouping, decimalSep, thousandSep, and negativeOrder.
currencyUses currency values. Valid options for this category include locale, numDigits, leadingZero, grouping, decimalSep, thousandSep, negativeOrder, positiveOrder, and currencyLocale.
dateUses date values. Valid options for this category include locale, dateFormat, useAltCalendar, and useEnglishStringsAlways.
timeUses time values. Valid options for this category include locale, timeFormat, and noSeconds.
datetimeUses datetime values. Valid options for this category include locale, dateFormat, timeFormat, noSeconds, useAltCalendar, and useEnglishStringAlways.

The following sections list the values that may be used for the

bstrOptions parameter:

NameDescription
localeSpecifies the locale identifier (LCID). Defaults to the current user's LCID if not specified.
numDigitsSpecifies the number of fractional digits after the decimal separator. The value auto may also be used to indicate that the number of decimal places that was entered will be the number of decimal places in the output. For example, 1.234, 1.234, 1.00, 1.00, 1.56e2, or 156.00. Defaults to the corresponding value in regional settings if not specified.
leadingZeroSpecifies whether to use leading zeros in decimal fields. Specify 0 to indicate no leading zeros and 1 to indicate leading zeros. Defaults to the corresponding value in regional settings if not specified.
groupingSpecifies the size of each group of digits to the left of the decimal. Values in the range 0–9 and value 32 are valid. Value 32 indicates that the grouping is three digits, then two digits thereafter. Defaults to the corresponding value in regional settings if not specified.
decimalSepSpecifies the decimal separator string. Defaults to the corresponding value in regional settings if not specified.
thousandSepSpecifies the thousands separator string. Defaults to the corresponding value in regional settings if not specified.
negativeOrderSpecifies the negative number mode. Defaults to the corresponding value in regional settings if not specified.
positiveOrderSpecifies the positive number mode. Defaults to the corresponding value in regional settings if not specified.
currencyLocaleSpecifies the locale identifier (LCID) for the currency symbol. Defaults to the value specified by locale if not specified.
dateFormatSpecifies a format picture string that is used to form the date string. The values Short Date, Long Date, Year Month, and none may also be used to indicate short date format, long date format, year month format, and no format, respectively. Short Date, Long Date, and Year Month are the default formats provided by the operating system's regional and language settings.
useAltCalendarSpecifies whether to use an alternate calendar for date formatting. Specify 0 to use the normal calendar and 1 to use the alternate calendar. Defaults to 0 if not specified.
useEnglishStringsAlwaysSpecifies whether to always use English strings for date formatting. Specify 0 to use the language specified by locale and 1 to always use English. Defaults to 0 if not specified.
timeFormatSpecifies a format string that is used to form the time string. The value none may also be used to indicate no format. Defaults to the time format in regional settings if not specified.
noSecondsSpecifies whether to not use seconds. Specify 0 to use seconds and 1 to not use seconds. Defaults to 0 if not specified.
Security Level 0: Can be accessed without restrictions.

Example

In the following example, the FormatString method of the Application object is used to format the specified date string into a long date format:

JScript
Application.FormatString("2006-01-08", "date", "dateFormat:Long Date");



Show: