当值超过100,000+时,Cint溢出错误

Tom*_*ggs 19 vbscript

我是编程的新手,并且遇到了Cint溢出错误的麻烦.每当值达到100,000+时,我都会收到Cint溢出错误.这是我编程课程的一个练习练习.据我所知,我在实践中完全按照它编写的方式对其进行了编码,但实践表明使用的值高达300,000.有人可能会解释我可能做错了什么吗?

<script language="VBscript">
Option Explicit
DIM numberofshifts, totalshift1, totalshift2, _
  totalshift3, grandtotal, shiftaverage
numberofshifts=3
totalshift1 = Inputbox("How many widgets during the first shift")
totalshift2 = Inputbox("How many widgets during the second shift")
totalshift3 = Inputbox("How many widgets during the third shift")
grandtotal = cint(totalshift1) + totalshift2 + totalshift3
shiftaverage = grandtotal / numberofshifts
Document.write "The Total of the Three Shifts is " & grandtotal
Document.write "<br>The Average of the Three Shifts is " & shiftaverage
</script>
Run Code Online (Sandbox Code Playgroud)

Rom*_*meo 39

CInt 可以处理-32,768和32,767之间.

CLng而不是CInt.

MSDN参考

  • 供参考:[VBScript数据类型](http://msdn.microsoft.com/en-us/library/9e7a57cf%28VS.84%29.aspx) (2认同)