This is a migrated thread and some comments may be shown as answers.

Format function remove trailing zeros in expression

2 Answers 848 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dustin
Top achievements
Rank 1
Dustin asked on 08 Feb 2016, 05:47 PM
I am having an extremely difficult time doing a simple task. I need to create a text box that contains both text and a decimal from my database. I want to add formatting to the decimal to remove all trailing zeros (not round, I want the full number displayed just not trailing zeros). Below is my current textbox value and the result;
='Acreage:  '+ Fields.AssignmentAcres
Acreage:  640.000000000000000000
I've tried every iteration I can think of with the format function to no avail. Below is what I assume the textbox should look like but I keep receiving errors.
='Acreage:  '+Format(Fields.AssignmentAcres, '####################.######################')
I've tried with single quotes, double quotes, no quotes, I even tried the formatting '0000.0000....'. No matter what I keep receiving errors. Please keep in mind that I am not a developer, I do not know coding very well. I've seen several answers googling this that requires quite a bit of code and I have no idea where to even put that code. I am using the "Edit Expression" dialog box to enter my field values. Thanks

2 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 09 Feb 2016, 12:14 PM
Hello Dustin,

You need to use a different syntax for the Format(format, args) text function:

= 'Acreage: ' + Format('{0:####################.######################}', Fields.value)

The first argument is the format. The second in this case is the value. You can also find example usages in the Edit Expression window.
Additional information on the topic is present in the Custom Numeric Format Strings MSDN page.

Regards,
Nasko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Dustin
Top achievements
Rank 1
answered on 09 Feb 2016, 06:16 PM
That is perfect, thanks so much
Tags
General Discussions
Asked by
Dustin
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Dustin
Top achievements
Rank 1
Share this question
or