Negative numbers in calculations - help...

ndeans

Registered User.
Local time
Tomorrow, 00:31
Joined
Jun 5, 2006
Messages
39
Ok i know negative numbers can be a bugger in calculations bt i can't seem to wrap my head around this one:

Code:
Function FEV1pred(height As Double, ClientID As Double) As Double

Dim a As Double
Dim Age As Integer 
Dim DOB As Date
Dim TestDate As Date

Age = DateDiff("yyyy", DOB, TestDate) + CInt(Format(DOB, "mmdd") > Format(TestDate, "mmdd"))
'In this case the clients Age is 39
a = -0.0244

'Now for the fun stuff...

FEV1pred = a
'returns -0.0244 so i know the dim a holds the neg number

FEV1pred = (a * Age)
'returns 1.708 (which is [B]incorrect[/B], absolutely no idea how this calculation is reached.)

FEV1pred = (a * 39)
'returns -0.9516 (which is [B]correct[/B])

End Function


So something about the dimming of Age seems to be doing something to the equation but i can't work out what?

Any help much appreciated folks...


Oh man... The Stupidity Is Real... Age calculation was missing a date value... Must have been a long day. Thanks for your reply smig
 
Last edited:

Users who are viewing this thread

Back
Top Bottom