Overflow when multiplying Integers and assigning to Long

后端 未结 2 1889
猫巷女王i
猫巷女王i 2020-12-03 21:50

If I type the following into the immediate window I get Runtime error \'6\': Overflow.

MsgBox 24 * 60 * 60

Why is this?

This also

2条回答
  •  忘掉有多难
    2020-12-03 22:19

    After every number, place #. It defines each number as a double. Think of it as, each number is placed in to memory for the calculation as sort of a temp variable. If you define each number, it will allow enough space for the calculations.

    eg:

    Dim x As Long

    x = 24# * 60# * 60#

    or 24& 'indicates long

提交回复
热议问题