此代码应返回0,但它返回1. VBA似乎正在进行浮点数学运算,即使所有数字都是长整数。
Function demo() As Long
Dim const1 As Long
Dim const2 As Long
Dim result As Long
const1 = 1796&
const2 = 1798&
result = const1 / const2
demo = result
End Function
答案 0 :(得分:4)
更改斜线的方向
Function demo() As Long
Dim const1 As Long
Dim const2 As Long
Dim result As Long
const1 = 1796&
const2 = 1798&
result = const1 \ const2
demo = result
End Function
\
将强制进行整数除法