tmighty
tmighty

Reputation: 11399

Why does long l = 1000 * 60 cause overflow?

I have this line:

    Dim l&
    l = 1000 * 60 '1 min

It throws an overflow error.

Why is that?

Upvotes: 2

Views: 98

Answers (1)

John Eason
John Eason

Reputation: 571

Vb's Help says:

You attempt to use a number in a calculation, and that number is coerced into an integer, but the result is larger than an integer. For example:

Dim x As Long
x = 2000 * 365   ' Error: Overflow

To work around this situation, type the number, like this:

Dim x As Long
x = CLng(2000) * 365

Upvotes: 5

Related Questions