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

R

Robert

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?
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top