>>
>>-----Original Message-----
>> >From: <
.....piclist-bouncesKILLspam
@spam@mit.edu>
piclist-bounces
KILLspammit.edu On Behalf
>> Of Dennis Crawley
>> >Sent: Sunday, March 27, 2005 6:05 PM
>> >
>> >Hi,
>> >I don't understand why VB rises an overflow error
>> >when this is performed
>> >
>> >DELFN = 84 / (256 * (256 * (256 * (3 + beta) + 2) + 2) + 2)
>> >
>> >but nothing happens if is written like this
>> >
>> >DELFN = 84 / (256 * (Val(256) * (256 * (3 + beta) + 2) + 2) + 2)
>> > ^^^
>> >VB mysteries?
>
>
>Is the variable beta defined as an integer? If yes then:
>
>In most, if not all, Basic dialects the variable beta will be used to hold
>the intermediate results during calculation. (256 * (3 + beta) + 2) fits
>into an integer but the next * 256 overflows an integer sized variable.
>
>I believe the Val(256) function call is returning a variant that is used for
>the remaining intermediate calculations avoiding the overflow condition.
>While this works I don't think VB guarantees this method to work so, I
>recommend you define beta as a long instead of an integer. Alternatively you
>can copy beta to a long and use the long in the calculation.
>
>Paul Hutch