Cint overflow error when value exceeds 100,000+

前端 未结 2 823
情歌与酒
情歌与酒 2021-01-07 19:31

I am brand new to programming and am running into some trouble with Cint overflow error. Whenever the value reaches 100,000+ I get a Cint overflow error. This was a practi

相关标签:
2条回答
  • 2021-01-07 19:42

    CInt can handle betweeen -32,768 and 32,767.

    Use CLng instead of CInt.

    MSDN Reference

    0 讨论(0)
  • 2021-01-07 19:42

    Converting string data to integers may be accomplished by using CInt() CLng() or CDbl(). It is important to remember the size limitations of these data types. Different programming languages have different limitations.
    Here is a link to VBScript Data Types.

    Integers can handle integers from -32,768 to 32,767. Long can handle integers from -2,147,483,648 to 2,147,483,647. Doubles can handle numbers up to 1.79769313486232E+308, (That's a bigger number than the number of atoms in the Sun, which is 1.19 octodecillion.) They are also double floating-point precision; meaning a double can also handle extremely precise decimal points.

    grandtotal = cdbl(totalshift1) + totalshift2 + totalshift3 
    

    This will eliminate the overflow problem. It won't handle the error if a user enters a non-number, but that's another topic.

    0 讨论(0)
提交回复
热议问题