我目前正在VBA中创建一个用户表单,您可以在其中输入数字,按计算,然后在文本框中返回答案。
目前,答案显示为10位以上的重要人物(见下文)。我需要做些什么才能让我的计算输出只显示3位小数?
谢谢!
计算输出示例:
答案 0 :(得分:1)
SELECT
SaleMonth, Month_Order_Count, MonthTotal,
SUM(Month_Order_Count) OVER(ORDER BY SaleMonth **ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW**) AS Cumulative_Order_Count,
SUM(MonthTotal) OVER(ORDER BY SaleMonth **ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW**) AS Cumulative_Order_Value
FROM
(
SELECT SUB_Q.SaleMonth, Count( DISTINCT SUB_Q.OrderID) as Month_Order_Count, SUM(Value) as MonthTotal FROM
(
SELECT CONCAT( DatePart( year, OH.OrderDate), '-', FORMAT( OH.OrderDate, 'MM')) as SaleMonth,
OI.OrderID,
OI.Value
FROM ORDERHEADER OH
INNER JOIN OrderItem OI ON OI.OrderID = OH.OrderID
INNER JOIN ECodeOrder ECO ON ECO.OrderId = OH.ORDERID
) SUB_Q
GROUP BY SUB_Q.SaleMonth
)TOTALS_Q
ORDER BY SaleMonth
将执行此操作,只需在第二个参数中的小数点后添加更多或更少的Format(myAnswer, "0.00")
以更改有效数字。
Here是一个关于如何编写要在此函数中使用的数字格式的网站。
答案 1 :(得分:1)
尝试:TextBox1 = Round(Value, 3)