在VBA中计算const时溢出

Jon*_*ebb 10 vba const overflow

此声明导致VBA溢出:

Const OVERFLOWS As Long = 10 * 60 * 60
Run Code Online (Sandbox Code Playgroud)

而直接设置值是好的:

Const COMPILES_OK As Long = 36000
Run Code Online (Sandbox Code Playgroud)

你如何说服VBA将字面整数视为多头?

谢谢

xsl*_*xsl 14

long后缀添加&到至少一个数字:

Const OVERFLOWS As Long = 10& * 60 * 60
Run Code Online (Sandbox Code Playgroud)

请注意,使用CLNG函数将值转换为long不起作用,因为VBA不允许将函数的返回值赋值为常量.