VBA 函数只产生零。不知道为什么
VBA function just yielding zero. Cannot figure out why
当我在 Excel 中手动执行时,我得到的数字与 VBA 函数的数字不同。函数如下图
Function TimeEstimate(InstanceCount As Integer, Grouping As Integer, DaysPerBoard As Integer, _
MinRunTime As Integer, XShift As Integer)
If InstanceCount <= 0 Then
TimeEstimate = 0
ElseIf Application.RoundUp((InstanceCount + XShift) / Grouping, 0) * Grouping * DaysPerBoard < MinRunTime Then
TimeEstimate = MinRunTime
Else
TimeEstimate = Application.RoundUp((InstanceCount + XShift) / Grouping, 0) * Grouping * DaysPerBoard
End If
End Function
一些示例数据:
实例数:1
分组:10
每板天数:0.03
最小运行时间:0.5
XShift:0
正确计算后,您应该得到 0.5(MinRuntime),但我得到零。
您所有的变量都定义为integer
。使用 double
作为小数,而不是
当我在 Excel 中手动执行时,我得到的数字与 VBA 函数的数字不同。函数如下图
Function TimeEstimate(InstanceCount As Integer, Grouping As Integer, DaysPerBoard As Integer, _
MinRunTime As Integer, XShift As Integer)
If InstanceCount <= 0 Then
TimeEstimate = 0
ElseIf Application.RoundUp((InstanceCount + XShift) / Grouping, 0) * Grouping * DaysPerBoard < MinRunTime Then
TimeEstimate = MinRunTime
Else
TimeEstimate = Application.RoundUp((InstanceCount + XShift) / Grouping, 0) * Grouping * DaysPerBoard
End If
End Function
一些示例数据:
实例数:1
分组:10
每板天数:0.03
最小运行时间:0.5
XShift:0
正确计算后,您应该得到 0.5(MinRuntime),但我得到零。
您所有的变量都定义为integer
。使用 double
作为小数,而不是