Share via


_Application3.FormatString method (Object, String, String)

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

Namespace:  Microsoft.Office.Interop.InfoPath.SemiTrust
Assembly:  Microsoft.Office.Interop.InfoPath.SemiTrust (in Microsoft.Office.Interop.InfoPath.SemiTrust.dll)

Syntax

'Declaration
Function FormatString ( _
    varInput As Object, _
    bstrCategory As String, _
    bstrOptions As String _
) As String
'Usage
Dim instance As _Application3
Dim varInput As Object
Dim bstrCategory As String
Dim bstrOptions As String
Dim returnValue As String

returnValue = instance.FormatString(varInput, _
    bstrCategory, bstrOptions)
string FormatString(
    Object varInput,
    string bstrCategory,
    string bstrOptions
)

Parameters

  • varInput
    Type: System.Object

    The value or XML node to be formatted.

  • bstrCategory
    Type: System.String

    The value that specifies the category used for formatting. Values include number, percentage, currency, date, time, and datetime.

  • bstrOptions
    Type: System.String

    The value that specifies the options used for formatting. Takes the form of a case-sensitive string in the format "optionName:value".

Return value

Type: System.String
A string formatted according to the specified category and options parameters.

Implements

_Application2.FormatString(Object, String, String)
_Application.FormatString(Object, String, String)

Remarks

The FormatString method can be used anywhere you need to change the format of a specified string. It must be qualified with the Application 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 bstrCategory and bstrOptions:

List of categories

Name

Description

number

Uses numerical values. Valid options for this category include "locale", "numDigits", "leadingZero", "grouping", "decimalSep", "thousandSep", and "negativeOrder".

percentage

Uses percentage values. Valid options for this category include "locale", "numDigits", "leadingZero", "grouping", "decimalSep", "thousandSep", and "negativeOrder".

currency

Uses currency values. Valid options for this category include "locale", "numDigits", "leadingZero", "grouping", "decimalSep", "thousandSep", and "negativeOrder", "positiveOrder", and "currencyLocale".

date

Uses date values. Valid options for this category include "locale", "dateFormat", "useAltCalendar", and "useEnglishStringsAlways".

time

Uses time values. Valid options for this category include "locale", "timeFormat", and "noSeconds".

datetime

Uses datetime values. Valid options for this category include "locale", "dateFormat", "timeFormat", "noSeconds", "useAltCalendar", and "useEnglishStringAlways".

List of options

Name

Description

locale

Specifies the locale identifier (LCID). Defaults to the current user's LCID if not specified.

numDigits

Specifies 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.

leadingZero

Specifies 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.

grouping

Specifies 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.

decimalSep

Specifies the decimal separator string. Defaults to the corresponding value in regional settings if not specified.

thousandSep

Specifies the thousands separator string. Defaults to the corresponding value in regional settings if not specified.

negativeOrder

Specifies the negative number mode. Defaults to the corresponding value in regional settings if not specified.

positiveOrder

Specifies the positive number mode. Defaults to the corresponding value in regional settings if not specified.

currencyLocale

Specifies the locale identifier (LCID) for the currency symbol. Defaults to the value specified by locale if not specified.

dateFormat

Specifies 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.

useAltCalendar

Specifies 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.

useEnglishStringsAlways

Specifies 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.

timeFormat

Specifies 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.

noSeconds

Specifies whether to not use seconds. Specify 0 to use seconds and 1 to not use seconds. Defaults to 0 if not specified.

Examples

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

string myDate = thisApplication.FormatString(
   "2003-01-08", "date", "dateFormat:Long Date");
Dim myDate As String = thisApplication.FormatString( _
   "2003-01-08", "date", "dateFormat:Long Date")

See also

Reference

_Application3 interface

_Application3 members

FormatString overload

Microsoft.Office.Interop.InfoPath.SemiTrust namespace