How To Use Custom Format And Text In Data Display And Data Edit Objects In NA HMI
Data Display and Edit Objects allow you to format how the value is displayed on the NA screen using the 'ValueFormat' property. Sometimes it is necessary to fully customise the field so it displays a mixture of text and the value formatted in a specific way. This article shows how to use the custom format on a Display or Edit object.
Once you have selected the Display/Edit object, change the 'ValueFormat' property to 'Custom' as shown on the picture below:
Once 'Custom' format is selected you can choose your format and do further customization in the field provided:
As the custom display field can hold a combination of string data and value data, an identifier is required to identify where to insert the value. NA uses Visual Basic .NET framework so it uses the same placeholders. In this case the value data is inserted by adding {0:XXXX} where XXXX is your numeric format as described below.
Difference between "0" and "#"
"0" - Replaces the zero with the corresponding digit if one is present; otherwise, zero appears in the result string.
"#" - Replaces the "#" symbol with the corresponding digit if one is present; otherwise, no digit appears in the result string.
Examples
{0:##.##} will display '12.24'
{0:##} will display ‘12’
{0:000.000} will display ‘012.240’
Text Customization
It is possible to add additional text that will be displayed in Data Edit and Data Display.
The correct syntax to do that is as follows:
myText {0:my format} myText.
So if you edit your Data Display or Data Edit object in the is way:
The NA Runtime will look as follows:
Other Examples:
Current Speed = {0:##,###} widgets\hour will display 'Current Speed = 12,345 widgets\hour'
Current Speed = {0:0} widgets\sec will display 'Current Speed = 7 widgets\sec'
Current Speed = {0:00.000} widgets\sec will display 'Current Speed = 07.444 widgets\sec'
Further Information
If you want to learn more about Custom Numeric Format Strings, please read this Microsoft article.
Warning
Any text entered this way will not be added to The NA Resources and will not be translatable.