2.3.6. Format Strings

Controls like text labels, gauges, and level indicators that can display text or numbers have a Format String property that allows you to format the text. This is particularly useful for numbers.

Standard Numeric

Standard numeric values use Windows Standard Numeric Format Strings.

Examples:

Input ValueFormat StringDisplayed
0.1234 E2 1.23E-001
0.1234 P2 12.34%

The following formats are supported:

Numeric typeFormat string
DecimalD or d
ExponentialE or e
FixedF or f point
GeneralG or g
NumberN or n
PercentP or p
Round-tripR or r
HexadecimalX or x
All digits @

[Note]

Applying format strings may cause precision to be lost if there is a long string of digits in the number. To preserve the entire string of digits, set the format string to @. This is specific to the WebView application, and not a Windows format string.

Custom Numeric

Custom numeric values use Windows Custom Numeric Format Strings, which typically consist of one or more instances of the custom numeric specifiers 0 and #. Two- and three-part custom numeric format strings are also valid, using semi-colons to delimit the parts.

Examples:

Input ValueFormat StringDisplayed
5678 #,##0.00 5,678.00
5678 My 0 data points. My 5678 data points.
123.456 #.#;(####) 123.5
-123.456 #.#;(####) (123)
0 #.#;(####);zero zero

Text Values

You can build composite strings by using the {0} placeholder to insert a text value.

Examples:

Input ValueFormat StringDisplayed
OFF The alarm is {0} The alarm is OFF
High Tank level: {0} Tank level: High

Dates

Both standard and custom date format strings are supported, using Windows Standard or Custom Date and Time Format Strings, respectively.

Examples:

Input ValueFormat StringDisplayed
May 9, 2016, 3:58 PM d 05/09/2016
May 9, 2016, 3:58 PM f Tuesday, 09 May, 2016 15:58
07/14/2016 08:15:25 yyyy-MM-dd hh:mm tt 2016-07-14 08:15 AM