千位分隔符与自动小数位数组合 [英] Thousand separator in combination with automatically amount decimal places

查看:126
本文介绍了千位分隔符与自动小数位数组合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


为了能够输入带小数位的值,表中的字段我设置为单一数据类型。
属性 格式(表单或报告中的控件)我设置为"常规编号"。结果是小数点右边没有数字(或零)。当
的值位于小数点右侧时结束,将显示。到目前为止,结果是完美的。

To able to enter values with decimal places, the field in the table I set to a Single data type. The property Format (of the control in a form or report) I set to "General Number". The result is that no digits (or zero's) will be shown tot the right of the decimal place. End when the value has digits tot the right of the decimal place, it will be shown. Until so far the result is perfect.

现在我想使用相同的结果 千位分隔符结合使用。我更愿意用
格式函数来实现这个目标,因为在这种情况下没有必要为此编写特定的函数,但我无法搞清楚如何实现格式函数的这个目标。

Now I want to use the same result combined with the thousand separator. I would prefer to achieve this goal with the Format Function, because in that case there is no need to write a specific function for this, but I can't figger it out how to achieve this goal with the Format Function.

推荐答案

在表格字段,格式属性中,只需输入#,###表示无小数, #,###。##如果你想要它们。

In the Table Field, Format Property, just type #,### for no decimals, #,###.## if you want them.

你也可以在Form(或Report)字段的'Format'属性中输入它。

You can also just type that into the 'Format' property for the Form (or Report) Field.

在表单或报表中,您还可以尝试将控制源设置为=格式([FieldName],"##,###。##")。这意味着控制变为计算控制&不会在表单中编辑

In a form or report, you can also try setting the Control Source to =Format([FieldName],"##,###.##"). This means the control becomes a calculated control & wouldn't be edited In a form

您还可以通过使用此代码测试各种格式字符串来查看Format函数的工作原理:

You can also see how the Format function works by using this code to test the various format strings:

Public Sub TestThis()
    MsgBox "100000.16, Formatted (No Decimals) = " & Format("100000.16", "##,###") & " Formatted (2 Decimal) = " & Format("100000.168", "##,###.##")
End Sub


这篇关于千位分隔符与自动小数位数组合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆