# ToString
{: .no_toc }

Returns the text of the format item that the properties describe.

Syntax: *object*.**ToString** ( ) **As String**

*object*
: *required* An object expression that evaluates to a **StringFormatSpecifier**.

Returns a **String**: an opening brace, the [**Index**](/tB/Packages/Contributed/Fmt/StringFormatSpecifier/IndexProperty.md), a comma and the [**Alignment**](/tB/Packages/Contributed/Fmt/StringFormatSpecifier/Alignment.md) when the alignment is not zero, a colon and the [**identifier**](/tB/Packages/Contributed/Fmt/StringFormatSpecifier/identifier.md) when the identifier is not empty, the [**CustomSpecifier**](/tB/Packages/Contributed/Fmt/StringFormatSpecifier/CustomSpecifier.md), and a closing brace.

## Remarks

[**StringHelper**](/tB/Packages/Contributed/Fmt/StringHelper.md) calls **ToString** to find the item again in the text it is building, and replaces that text with the formatted value. An item that is written differently from the text that **ToString** builds therefore stays in the result unchanged. This happens to an index or an alignment written with a leading zero (`{00}`, `{0,08}`) and to an alignment of zero (`{0,0}`), because the rebuilt text is `{0}` or `{0,8}`.

```tb check_build check_run
Debug.Print StringFormat("[{0}]", 5)      ' [5]
Debug.Print StringFormat("[{00}]", 5)     ' [{00}]
Debug.Print StringFormat("[{0,08}]", 5)   ' [{0,08}]
Debug.Print StringFormat("[{0,0}]", 5)    ' [{0,0}]
```

## Example

```tb check_build check_run
Dim spec As New StringFormatSpecifier
Debug.Print spec.ToString()  ' {0}

spec.Index = 1
spec.Alignment = 8
spec.identifier = "F"
spec.CustomSpecifier = "2"
Debug.Print spec.ToString()  ' {1,8:F2}
```

## See Also

- [Index](/tB/Packages/Contributed/Fmt/StringFormatSpecifier/IndexProperty.md) property -- the position of the value
- [Alignment](/tB/Packages/Contributed/Fmt/StringFormatSpecifier/Alignment.md) property -- the width of the value
- [identifier](/tB/Packages/Contributed/Fmt/StringFormatSpecifier/identifier.md) property -- the format letter
- [CustomSpecifier](/tB/Packages/Contributed/Fmt/StringFormatSpecifier/CustomSpecifier.md) property -- the text after the letter
- [StringFormatSpecifier](/tB/Packages/Contributed/Fmt/StringFormatSpecifier/index.md) class -- overview
