Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime Error 13 Type Mismatch Arturo Excel Programming 1 January 31st 07 03:24 PM
Runtime Error Type 13 Mismatch Linking to specific cells in pivot table Excel Programming 5 May 31st 06 05:31 PM
Runtime Error '13': Type mismatch Linking to specific cells in pivot table Excel Programming 2 May 18th 05 07:34 PM
Runtime error 13 type mismatch ? JoeH[_18_] Excel Programming 1 September 25th 04 08:23 PM
Runtime error 13 type mismatch ? JoeH[_16_] Excel Programming 0 September 25th 04 06:44 PM


All times are GMT +1. The time now is 02:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"