Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 100ths of a second

is it possible to calculate 100ths or even 1000ths of a second in Excel.

I can calculate the time difference between 2 cells down to the second, but
is it possible to calculate down to the 100th of a second?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default 100ths of a second

Use the TimeGetTime API.

Option Explicit
Private lStartTime As Long
Private Declare Function timeGetTime Lib "winmm.dll" () As Long

Sub StartSW()
lStartTime = timeGetTime()
End Sub

Function StopSW(Optional bMsgBox As Boolean = True, _
Optional vMessage As Variant, _
Optional lMinimumTimeToShow As Long = -1) As Variant

Dim lTime As Long

lTime = timeGetTime() - lStartTime

If lTime lMinimumTimeToShow Then
If IsMissing(vMessage) Then
StopSW = lTime
Else
StopSW = lTime & " - " & vMessage
End If
End If

If bMsgBox Then
If lTime lMinimumTimeToShow Then
MsgBox "Done in " & lTime & " msecs", , vMessage
End If
End If

End Function


Sub test()

Dim i As Long

StartSW
For i = 1 To 10000000

Next i
StopSW

End Sub


RBS



"TADropik" wrote in message
...
is it possible to calculate 100ths or even 1000ths of a second in Excel.

I can calculate the time difference between 2 cells down to the second,
but
is it possible to calculate down to the 100th of a second?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 100ths of a second

That worked perfect.
Thank you for that.

Now if I can just get macros to run on my Cell Phone I have a nice little
stop watch to carry with me. ;-)


"RB Smissaert" wrote:

Use the TimeGetTime API.

Option Explicit
Private lStartTime As Long
Private Declare Function timeGetTime Lib "winmm.dll" () As Long

Sub StartSW()
lStartTime = timeGetTime()
End Sub

Function StopSW(Optional bMsgBox As Boolean = True, _
Optional vMessage As Variant, _
Optional lMinimumTimeToShow As Long = -1) As Variant

Dim lTime As Long

lTime = timeGetTime() - lStartTime

If lTime lMinimumTimeToShow Then
If IsMissing(vMessage) Then
StopSW = lTime
Else
StopSW = lTime & " - " & vMessage
End If
End If

If bMsgBox Then
If lTime lMinimumTimeToShow Then
MsgBox "Done in " & lTime & " msecs", , vMessage
End If
End If

End Function


Sub test()

Dim i As Long

StartSW
For i = 1 To 10000000

Next i
StopSW

End Sub


RBS



"TADropik" wrote in message
...
is it possible to calculate 100ths or even 1000ths of a second in Excel.

I can calculate the time difference between 2 cells down to the second,
but
is it possible to calculate down to the 100th of a second?



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
How can I count min bt 100ths Excell novice Excel Discussion (Misc queries) 1 July 13th 06 03:19 PM
Calculating time worked using 100ths of an hour, from 1 day into n maintchief New Users to Excel 4 October 27th 05 11:48 PM
In Excel how do I format swimming times - mm.ss.100ths No Name Excel Programming 0 September 13th 04 02:12 PM
In Excel how do I format swimming times - mm.ss.100ths Tom Ogilvy Excel Programming 0 September 13th 04 02:03 PM
In Excel how do I format swimming times - mm.ss.100ths JE McGimpsey Excel Programming 0 September 13th 04 01:58 PM


All times are GMT +1. The time now is 08:48 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"