470,625 Members | 1,963 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,625 developers. It's quick & easy.

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

MLH
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.
Nov 13 '05 #1
6 1619
MLH
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?
Nov 13 '05 #2
(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

Nov 13 '05 #3

<le*********@natpro.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
(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


(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
Nov 13 '05 #4
MLH
On Wed, 7 Sep 2005 10:34:56 -0500, "paii, Ron" <pa**@packairinc.com>
wrote:

<le*********@natpro.com> wrote in message
news:11**********************@g47g2000cwa.googleg roups.com...
(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


(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

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.
Nov 13 '05 #5

"MLH" <CR**@NorthState.net> wrote in message
news:j8********************************@4ax.com...
On Wed, 7 Sep 2005 10:34:56 -0500, "paii, Ron" <pa**@packairinc.com>
wrote:

<le*********@natpro.com> wrote in message
news:11**********************@g47g2000cwa.googleg roups.com...
(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


(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

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.


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.
Nov 13 '05 #6
MLH
Well, you learn something new everyday.
I thought my computer was broke.

Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Alisher Fatykhov | last post: by
reply views Thread by Alisher Fatykhov | last post: by
reply views Thread by Alisher Fatykhov | last post: by
3 posts views Thread by Unknown | last post: by
4 posts views Thread by lenygold via DBMonster.com | last post: by
15 posts views Thread by student4lifer | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.