TX Text Control ActiveX

Number Formats

Topic

Results that table cells calculate are easier to read when they share a format. A number format tells TX Text Control ActiveX how to display the result of a cell formula: how many digits and decimal places, with which separators, as a percentage or together with a currency symbol or a word.

Formulas are defined with the TableCellFormula property, as Using Formulas in Table Cells describes. The sections below build number format strings from placeholders, separators, the percentage sign and added text, with an example for each character.

How Number Formats Work

By default, the number format is an empty string, and the cell shows the unformatted value of the calculation. A result without decimal places is displayed as an integer, and a decimal number is displayed with all its decimal places.

To display different results with a common format, set a number format string with the TableCellNumberFormat property. Like the formula, it is set for a cell identified by its table identifier, row and column. A number format string is composed of:

  • placeholders, # and 0,
  • separators, . and ,,
  • percentage signs, %, and
  • other single characters or text.

Reserve Digits With Placeholders

Placeholders stand for the digit positions of the number to format. Two characters are valid placeholders, # and 0. The placeholder 0 fills a position with a zero if no digit of the calculated result occupies it.

ValueFormatDisplayed as
7#7
789#789
1234#1234
7000007
789000789

Add Separators

Two separators display a number as a decimal number, with a thousands separator, or both. The separators are rendered with the default decimal and thousands separator signs of the system language: a German system, for example, uses a comma as the decimal sign and a point as the thousands separator.

Decimal Numbers

To display all numbers with decimal places, combine the placeholders with a decimal point (.). The number of placeholders after the point sets the maximum number of decimal places shown. Without a decimal point, results are rounded to the nearest integer.

ValueFormatDisplayed as
12.6#.##12.6
5#.005.00
12.6#.0012.60
0.543#.000.54
17.548#18

Thousands Separator

The second separator is the thousands separator (,). Followed by placeholders, it displays the result with a comma after every third digit. If no placeholder follows the comma, each comma trims the number by three positions before the decimal point.

ValueFormatDisplayed as
9876543210.1234,###.##9,876,543,210.12
9876543210,###9,876,543,210
12200000#,,12
12200000#.0,,12.2

Show Percentages

The percentage sign has a special meaning. Combined with one or more placeholders, it multiplies the calculated value by 100 and displays it with the percentage sign.

ValueFormatDisplayed as
0.52#%52%
1#%100%
0.003210.##%0.32%
0.52%#%52

Add Characters and Text

There are three ways to combine the calculated value with a single character or with text.

Predefined Characters

The following characters can be combined with a number format string directly:

CharacterValueFormatDisplayed as
$ (dollar sign)500#$500$
- (minus sign)1-#.00-1.00
+ (plus sign)12.345+.##+12.35
/ (slash mark)4\1/#1/4
( (left parenthesis)7-(#+\3)-(7+3)
) (right parenthesis)3-(\7+#)-(7+3)
: (colon)50#:"50"50:50
! (exclamation point)6#!6!
^ (circumflex accent, caret)2.5#.00^\22.50^2
& (ampersand)0#&\10&1
' (apostrophe)9'#''9'
~ (tilde)7.654~#.0~7.7
{ (left curly bracket)67{-#}{-67}
} (right curly bracket)17{+#}{+17}
< (less-than sign)5#<"10"5<10
> (greater-than sign)7.4#.00>\67.40>6
= (equal sign)5.6#>=\66>=6
Space character12#.00 $12.00 $

Other Characters

Any other character, such as a specific currency symbol, is displayed when you put a backslash directly in front of it:

ValueFormatDisplayed as
12.99#.00\€12.99€
42\"#\""42"
18#:\X18:X

Words and Text

To add whole words or text, put them in quotation marks:

ValueFormatDisplayed as
29.99"EUR"#.00EUR 29.99
4.50#.00"€"4.50€
76# "Units"76 Units