Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Mod and Int gives me a Runtime Error 13 -- Type mismatch.
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? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Mod and Int gives me a Runtime Error 13 -- Type mismatch.
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 "Robert" wrote: 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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Runtime Error 13 Type Mismatch | Excel Programming | |||
Runtime Error Type 13 Mismatch | Excel Programming | |||
Runtime Error '13': Type mismatch | Excel Programming | |||
Runtime error 13 type mismatch ? | Excel Programming | |||
Runtime error 13 type mismatch ? | Excel Programming |