Connecting Tech Pros Worldwide Help | Site Map

A97 overflow error returned when trying to calculate 192/(24*60*60) - why?

MLH
Guest
 
Posts: n/a
#1: Nov 13 '05
I have the following procedure in a form module in A97. I have
the NewOutRefDate global var declared in a standard module
named "Declarations". It is dim'd as Variant.

Private Sub Command9_Click()
NewOutRefDate = 192 / (24 * 60 * 60)
Debug.Print NewOutRefDate
End Sub

The attempted assignment fails with an overflow error when it
runs. Anybody know why? I thought variant sufficient to handle
this calculation.
MLH
Guest
 
Posts: n/a
#2: Nov 13 '05

re: A97 overflow error returned when trying to calculate 192/(24*60*60) - why?


The following code gives me an error
Private Sub Command9_Click()
Dim MyDbl As Double
MyDbl = 192 / (24 * 60 * 60)
Debug.Print MyDbl


But the following does not...
Private Sub Command9_Click()
Dim MyDbl As Double
MyDbl = 4 / 7
Debug.Print MyDbl

I thought this unusual. Am I doing something wrong?
lesperancer@natpro.com
Guest
 
Posts: n/a
#3: Nov 13 '05

re: A97 overflow error returned when trying to calculate 192/(24*60*60) - why?


(24 * 60 * 60) must be trying to evaluate to an integer

192 / (cdbl(24) * 60 * 60) seems to work = 2.22222222222222E-03

but I don't know why

paii, Ron
Guest
 
Posts: n/a
#4: Nov 13 '05

re: A97 overflow error returned when trying to calculate 192/(24*60*60) - why?



<lesperancer@natpro.com> wrote in message
news:1126069306.909737.300130@g47g2000cwa.googlegr oups.com...[color=blue]
> (24 * 60 * 60) must be trying to evaluate to an integer
>
> 192 / (cdbl(24) * 60 * 60) seems to work = 2.22222222222222E-03
>
> but I don't know why
>[/color]

(24 * 60 * 60) = 86400 which is a bigger number then an Integer can hold.

(cdbl(24) * 60 * 60) converts it to a double which can hold 86400


MLH
Guest
 
Posts: n/a
#5: Nov 13 '05

re: A97 overflow error returned when trying to calculate 192/(24*60*60) - why?


On Wed, 7 Sep 2005 10:34:56 -0500, "paii, Ron" <paii@packairinc.com>
wrote:
[color=blue]
>
><lesperancer@natpro.com> wrote in message
>news:1126069306.909737.300130@g47g2000cwa.googleg roups.com...[color=green]
>> (24 * 60 * 60) must be trying to evaluate to an integer
>>
>> 192 / (cdbl(24) * 60 * 60) seems to work = 2.22222222222222E-03
>>
>> but I don't know why
>>[/color]
>
> (24 * 60 * 60) = 86400 which is a bigger number then an Integer can hold.
>
> (cdbl(24) * 60 * 60) converts it to a double which can hold 86400
>[/color]
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I was thinking that declaring NewOutRefDate As Variant would take
care of any memory allocation requirements. I guess I was wrong. It
does seem strange, though. A variant is the one variable type that
is big enough to manage any of the others.
paii, Ron
Guest
 
Posts: n/a
#6: Nov 13 '05

re: A97 overflow error returned when trying to calculate 192/(24*60*60) - why?



"MLH" <CRCI@NorthState.net> wrote in message
news:j83uh11u4imvau7n7vq8ms3o7jomnmc4kt@4ax.com...[color=blue]
> On Wed, 7 Sep 2005 10:34:56 -0500, "paii, Ron" <paii@packairinc.com>
> wrote:
>[color=green]
> >
> ><lesperancer@natpro.com> wrote in message
> >news:1126069306.909737.300130@g47g2000cwa.googleg roups.com...[color=darkred]
> >> (24 * 60 * 60) must be trying to evaluate to an integer
> >>
> >> 192 / (cdbl(24) * 60 * 60) seems to work = 2.22222222222222E-03
> >>
> >> but I don't know why
> >>[/color]
> >
> > (24 * 60 * 60) = 86400 which is a bigger number then an Integer can[/color][/color]
hold.[color=blue][color=green]
> >
> > (cdbl(24) * 60 * 60) converts it to a double which can hold 86400
> >[/color]
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> I was thinking that declaring NewOutRefDate As Variant would take
> care of any memory allocation requirements. I guess I was wrong. It
> does seem strange, though. A variant is the one variable type that
> is big enough to manage any of the others.[/color]

A variant will store anything, but Access creates temporary storage while
doing math functions.
24, 60, 60 are all Integer so Access creates an Integer to store the
calculation,
then fails when the result overflows the Integer.


MLH
Guest
 
Posts: n/a
#7: Nov 13 '05

re: A97 overflow error returned when trying to calculate 192/(24*60*60) - why?


Well, you learn something new everyday.
I thought my computer was broke.

Closed Thread