公式字段中的数字到字符串

发布于 2024-07-20 14:49:20 字数 198 浏览 2 评论 0原文

我正在使用公式字段来连接由破折号分隔的 2 个小数值。 但是,我希望结果修剪两个值的所有不必要的尾随零和小数点。

例如,我希望值 10 和 8.5 为“10 - 8.5”。 现在显示“10.00 - 8.50”。

我使用的公式是CSTR({field1}) + " - " + CSTR({field2})。

I am using a formula field to concatonate 2 decimal values separated by a dash. However, I want the result to trim all unneccesary trailing zeros and decimal points for both values.

For example, I want values 10 and 8.5 to be "10 - 8.5". Now it shows "10.00 - 8.50".

The formula I am using is CSTR({field1}) + " - " + CSTR({field2}).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

伪装你 2024-07-27 14:49:20

我相信这就是您正在寻找的:

将十进制数字转换为仅显示非零小数的文本

特别是这一行可能会有所帮助:

StringVar text     :=  Totext ( {Your.NumberField} , 6 , ""  )  ;

第一个参数是要转换的小数,第二个参数是小数位数,第三个参数是千/百万等的分隔符。

I believe this is what you're looking for:

Convert Decimal Numbers to Text showing only the non-zero decimals

Especially this line might be helpful:

StringVar text     :=  Totext ( {Your.NumberField} , 6 , ""  )  ;

The first parameter is the decimal to be converted, the second parameter is the number of decimal places and the third parameter is the separator for thousands/millions etc.

冷默言语 2024-07-27 14:49:20
CSTR({number_field}, 0, '')

第二个占位符用于小数。

最后一个占位符用于千位分隔符。

CSTR({number_field}, 0, '')

The second placeholder is for decimals.

The last placeholder is for thousands separator.

云胡 2024-07-27 14:49:20

我为此编写了一个简单的函数:

Function (stringVar param)
(
    Local stringVar oneChar := '0';
    Local numberVar strLen := Length(param);
    Local numberVar index := strLen;

    oneChar = param[strLen];

    while index > 0 and oneChar = '0' do
    (
        oneChar := param[index];
        index := index - 1;
    );

    Left(param , index + 1);
)

i wrote a simple function for this:

Function (stringVar param)
(
    Local stringVar oneChar := '0';
    Local numberVar strLen := Length(param);
    Local numberVar index := strLen;

    oneChar = param[strLen];

    while index > 0 and oneChar = '0' do
    (
        oneChar := param[index];
        index := index - 1;
    );

    Left(param , index + 1);
)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文