VB6 overflow error with large integers

前端 未结 3 1129
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-12 10:57

I am trying to set an integer value as such:

Dim intID as integer
intID = x * 10000

This works ok when x is 3 or less. But when

3条回答
  •  走了就别回头了
    2021-02-12 11:55

    In VB Integer variable range is -32,768 to 32,767 If any variable value is more than this range in your program,you have to declare Data type Long instead of Integer.

    Dim intID as integer
    intID = x * 10000
    
    Dim lngID AS Long
    
    lngID = x * CLng(10000)
    ' if 10000
    ' whatever you want to be
    

提交回复
热议问题