Classic ASP App CINT failure - twitpocalypse v2

浪尽此生 提交于 2019-12-13 13:05:06

问题


Due to a qty value exceeding what a VBScript INT can store, I'm getting a pretty nasty error message (actually the users are)... This is totally a case of twitpocalypse.

Since CINT() will not work in this situation, what is the best workaround?

requestqty = 40200
CInt() max = 32767

CInt(requestqty) 

EDIT
CLng() seems to do the trick, any risk to the code to change all CInt() to CLng(). From what I've read below and elsehwere on the web, it seems like there is really very little reason to even use CInt(). I didn't write this particular app and don't know why one was used over the other, but would prefer to not bandaid the issue and completely fix this issue in the app so it does not happen again...


回答1:


Aways use long instead of int in VBScript (unless you specifically want to limit the value to the int range).

There is no performance benefit for using the smaller type, and there is no storage size benefit because all variables are variants, so all simple types use the same amount of memory.

Use the CLng function instead of the CInt function.




回答2:


CLng or CDec or CDbl




回答3:


CLng() and using a Long instead of an Int?



来源:https://stackoverflow.com/questions/1195390/classic-asp-app-cint-failure-twitpocalypse-v2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!