Character Format

If the Format property does not begin with a percent symbol (%) but contains any number of (@) symbols, this formatting method will build a new string containing characters from the original, based upon the location of (@) symbols. This allows a phone number to be formatted according to a standard style. In this example, the original phone number should be a 10-digit number such as 8015551212. The following format string:

(@@@) @@@-@@@@ will generate the phone number: (801) 555-1212.

Each (@) symbol appends the next character from the original string. Any other character is appended literally. If an (@) symbol is encountered when the original string has no more characters, a space will be appended in its place. If the string begins with a dash (-) and contains (@) symbols, the character formatting begins from the last character in the original string and moves from right to left to the first character. The following format string is based on 8015551212:

-@@@-@@@@ and generates the string: 555-1212