For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > November 2005 > Overflow error









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Overflow error
Jack

2005-11-26, 9:55 pm

tmrScript.Interval = 65000 causes overflow error.
According to Microsoft the maximum is 65,535
Why is then such error?
Jack


Dmitriy Antonov

2005-11-27, 3:55 am


"Jack" <replyto@newsgroup> wrote in message
news:eEkpq2v8FHA.3224@TK2MSFTNGP09.phx.gbl...
> tmrScript.Interval = 65000 causes overflow error.
> According to Microsoft the maximum is 65,535
> Why is then such error?
> Jack
>


I've just tested it and couldn't reproduce this problem - no error raised,
when I assigned 65000 to Timer control. BTW, are we talking about VB's
standard Timer control, whose Interval property is of type Long?

Additionally, when I tried to assign 66000 to Interval, I got an error 380
(Invalid property value), which is different from the one specified.

So either you don't use standard control, or this is a problem of particular
build (I tested it onWinXP with VB SP5), or you use intermediate variable of
type integer before you assign its value to Interval property.

Dmitriy.


Phill W.

2005-11-29, 7:55 am

"Jack" <replyto@newsgroup> wrote in message
news:eEkpq2v8FHA.3224@TK2MSFTNGP09.phx.gbl...
> tmrScript.Interval = 65000 causes overflow error.
> According to Microsoft the maximum is 65,535


Do you /really/ have a line of code that says precisely

tmrScript.Interval = 65000

or something more like

tmrScript.Interval = x * y * 1000 ' or some other *calculation*

??

If it's the latter, VB will "optimise" its calcualtions to use the Integer
data type, and that "temporary result" is what's doing the overflowing,
not the [eventual] assignment to the Interval property.

HTH,
Phill W.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com