Mod and Int gives me a Runtime Error 13 -- Type mismatch.

Mod and Int gives me a Runtime Error 13 -- Type mismatch.

Post by Rober » Wed, 14 Mar 2007 22:46:42


I am trying to write the total processing time to a log file so I know
exactly how long my program takes to complete. I'm guessing the
variable iTotalSec isn't recognized as a number. Here's the function:

Public Function DeltaTime(dStart As Date, dStop As Date)
Dim iDay(2) As Double
Dim iHour(2) As Double
Dim iMin(2) As Double
Dim iSec As Double
Dim iTotalSec As Double

Dim Result As Double
Result = Evaluate("mod(3489936500, 1348993650)") '<= I tested this and
it works fine

iTotalSec = DateDiff("s", dStart, dStop)
iDay(0) = Evaluate("Int(iTotalSec/86400)") '<= This returns a type
mismatch.
iDay(1) = Evaluate("mod(iTotalSec,86400)")
iHour(0) = Evaluate("Int(iDay(0)/3600)")
iHour(1) = Evaluate("mod(iDay(1),3600")
iMin(0) = Evaluate("Int(iHour(0)/60)")
iMin(1) = Evaluate("mod(iHour(1),60)")
iSec = iMin(1)

AddToLog "Completed Audit in " & iDay(0) & " Days, " & iHour(0) & "
Hours, " _
& iMin(0) & " Minutes, " & iSec & " Seconds."

End Function

Is there a way to use the value of iTotalSec instead of the string in
the mod and int functions?
 
 
 

Mod and Int gives me a Runtime Error 13 -- Type mismatch.

Post by VG9tIE9naW » Wed, 14 Mar 2007 23:22:44

iDay(0) = Evaluate("Int(" & iTotalSec / 86400 & ")")

make the correction in all your formulas.
or use the VBA Int function

iday(0) = int(itotalsec / 86400)

itotalsec = 3000000
? int(itotalsec / 86400)
34



--
Regards,
Tom Ogilvy