StringBuilder: AppendFormatArrayEx

AppendFormatArrayEx

Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of a corresponding argument in a parameter array using a specified format provider.



 Public Function AppendFormatArrayEx(
	  ByVal Provider As IFormatProvider,
	  ByRef Format As String,
	  ByRef Args ( ) As Variant ) As StringBuilder

Parameters

Provider
[ByVal] IFormatProvider. An object that supplies culture-specific formatting information.
Format
[ByRef] String. A composite format string (see Remarks).
Args
[ByRef] Variant. An array of values to format.

Return Values

StringBuilder -  A reference to this instance after the append operation has completed. After the append operation, this instance contains any data that existed before the operation, suffixed by a copy of Format where any format specification is replaced by the string representation of the corresponding object argument.

Remarks

This method uses the composite formatting feature of VBCorLib to convert the value of an object to its text representation and embed that representation in the current StringBuilder object.

The Format parameter consists of zero or more runs of text intermixed with zero or more indexed placeholders, called format items, that correspond to values in the parameter list of this method. The formatting process replaces each format item with the string representation of the corresponding value.

The syntax of a format item is as follows:

{index[,length][:formatString]}

Elements in square brackets are optional. The following table describes each element.

ElementDescription
indexThe zero-based position in the parameter list of the object to be formatted. If the object specified by index is Nothing, the format item is replaced by an empty string. If there is no parameter in the index position, a FormatException is thrown.
,lengthThe minimum number of characters in the string representation of the parameter. If positive, the parameter is right-aligned; if negative, it is left-aligned.
:formatStringA standard or custom format string that is supported by the parameter.

The provider parameter specifies an IFormatProvider implementation that can provide formatting information for the objects in args. provider can be any of the following:

If the Provider parameter is Nothing, format provider information is obtained from the current culture.

Args represents the objects to be formatted. Each format item in Format is replaced with the string representation of the corresponding object in args. If the format item includes formatString and the corresponding object in Args implements the IFormattable interface, then Args(index).ToString(formatString, provider) defines the formatting. Otherwise, Object.ToString(Args(index)) defines the formatting.

See Also

Project CorLib Overview

Class StringBuilder Overview