Stupid VB glitch
-
... intDy = Int(lngCs / 86400) ' lngCS = 404090, intDy = 4 lngCs = lngCs - (intDy * 86400) ' no overflow, lngCs = 58490 intHr = Int(lngCs / 3600) ' intHr = 16 lngCs = lngCs - (intHr * 3600) ' overflow here, WTF?!? ...
How come the VB runtime can process int * 86400 but when it tries to multiply int * 3600 it gets an overflow? Is this just completely insane, or am I missing something?"You only disagree because you're a moron. If you were a man of intelligence you would see that I'm obviously right." - The General Consensus
-
... intDy = Int(lngCs / 86400) ' lngCS = 404090, intDy = 4 lngCs = lngCs - (intDy * 86400) ' no overflow, lngCs = 58490 intHr = Int(lngCs / 3600) ' intHr = 16 lngCs = lngCs - (intHr * 3600) ' overflow here, WTF?!? ...
How come the VB runtime can process int * 86400 but when it tries to multiply int * 3600 it gets an overflow? Is this just completely insane, or am I missing something?"You only disagree because you're a moron. If you were a man of intelligence you would see that I'm obviously right." - The General Consensus
86400 is treated as a Long while 3600 is treated as an Integer In the first case, the temporary is stored in a Long. The temporary result of the second one is stored in an Integer causing an overflow. Try: lngCs = lngCs - (intHr * CLng(3600))
-
86400 is treated as a Long while 3600 is treated as an Integer In the first case, the temporary is stored in a Long. The temporary result of the second one is stored in an Integer causing an overflow. Try: lngCs = lngCs - (intHr * CLng(3600))