Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Time a sub routine in thousanths of a second

With the following code provided by this forum I'm able to pause a sub
routine in thousanths of a second.
Is there a way to time how long it takes a sub routine to run in thousanths
of a second?


Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub SleepOneSecond()
Sleep 1000
End Sub

--
Regards,
Rocky McKinley




  #2   Report Post  
Posted to microsoft.public.excel.programming
jaf jaf is offline
external usenet poster
 
Posts: 300
Default Time a sub routine in thousanths of a second

Hi Rocky,
Sub test()
t-timer
'lots of code
t1=timer
debug.print t1-t 'or msgbox t1-t
end sub


--

John

johnf202 at hotmail dot com


"Rocky McKinley" wrote in message
...
With the following code provided by this forum I'm able to pause a sub
routine in thousanths of a second.
Is there a way to time how long it takes a sub routine to run in

thousanths
of a second?


Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub SleepOneSecond()
Sleep 1000
End Sub

--
Regards,
Rocky McKinley






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Time a sub routine in thousanths of a second

John, I tried your code and I get an error "Sub or Function not defined."

--
Regards,
Rocky McKinley


"jaf" wrote in message
...
Hi Rocky,
Sub test()
t-timer
'lots of code
t1=timer
debug.print t1-t 'or msgbox t1-t
end sub


--

John

johnf202 at hotmail dot com


"Rocky McKinley" wrote in message
...
With the following code provided by this forum I'm able to pause a sub
routine in thousanths of a second.
Is there a way to time how long it takes a sub routine to run in

thousanths
of a second?


Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub SleepOneSecond()
Sleep 1000
End Sub

--
Regards,
Rocky McKinley








  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Time a sub routine in thousanths of a second

Hi Rocky:

Sub TimeIt()
Dim StartTime As Double
StartTime = Timer
'lots of code here
MsgBox Format((Timer - StartTime)*1000, "#.00") & " milliseconds"
End Sub

Regards,

Vasant.




"Rocky McKinley" wrote in message
...
John, I tried your code and I get an error "Sub or Function not defined."

--
Regards,
Rocky McKinley


"jaf" wrote in message
...
Hi Rocky,
Sub test()
t-timer
'lots of code
t1=timer
debug.print t1-t 'or msgbox t1-t
end sub


--

John

johnf202 at hotmail dot com


"Rocky McKinley" wrote in message
...
With the following code provided by this forum I'm able to pause a sub
routine in thousanths of a second.
Is there a way to time how long it takes a sub routine to run in

thousanths
of a second?


Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub SleepOneSecond()
Sleep 1000
End Sub

--
Regards,
Rocky McKinley










  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Time a sub routine in thousanths of a second

Sub test()
t=timer '<===
'lots of code
t1=timer
debug.print t1-t 'or msgbox t1-t
end sub

--
regards,
Tom Ogilvy

Rocky McKinley wrote in message
...
John, I tried your code and I get an error "Sub or Function not defined."

--
Regards,
Rocky McKinley


"jaf" wrote in message
...
Hi Rocky,
Sub test()
t-timer
'lots of code
t1=timer
debug.print t1-t 'or msgbox t1-t
end sub


--

John

johnf202 at hotmail dot com


"Rocky McKinley" wrote in message
...
With the following code provided by this forum I'm able to pause a sub
routine in thousanths of a second.
Is there a way to time how long it takes a sub routine to run in

thousanths
of a second?


Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub SleepOneSecond()
Sleep 1000
End Sub

--
Regards,
Rocky McKinley












  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Time a sub routine in thousanths of a second

Thanks Guys

--
Regards,
Rocky McKinley


"Tom Ogilvy" wrote in message
...
Sub test()
t=timer '<===
'lots of code
t1=timer
debug.print t1-t 'or msgbox t1-t
end sub

--
regards,
Tom Ogilvy

Rocky McKinley wrote in message
...
John, I tried your code and I get an error "Sub or Function not

defined."

--
Regards,
Rocky McKinley


"jaf" wrote in message
...
Hi Rocky,
Sub test()
t-timer
'lots of code
t1=timer
debug.print t1-t 'or msgbox t1-t
end sub


--

John

johnf202 at hotmail dot com


"Rocky McKinley" wrote in message
...
With the following code provided by this forum I'm able to pause a

sub
routine in thousanths of a second.
Is there a way to time how long it takes a sub routine to run in
thousanths
of a second?


Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub SleepOneSecond()
Sleep 1000
End Sub

--
Regards,
Rocky McKinley












  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Time a sub routine in thousanths of a second

I use the class control provided by Karl Peterson for VB which should work
with VBA, grate for timing big storage loops etc

It uses the OS Multimedia timer and is very accurate and very easy to
stop/start.

he also has tip sheet about using

Can be found at http://www.mvps.org/vb/ file Stopwatch.zip

to use
add class to VBA project and in your code especially loops ...

'Create instance of stopwatch class
Set tmr = New CStopWatch
tmr.Reset


'to end after your code
StorageTime = tmr.Elapsed
LogFile "TIME for Data Storage:" & CStr(StorageTime / 1000) & " secs"

Cheers

Bob

"Rocky McKinley" wrote in message
...
Thanks Guys

--
Regards,
Rocky McKinley


"Tom Ogilvy" wrote in message
...
Sub test()
t=timer '<===
'lots of code
t1=timer
debug.print t1-t 'or msgbox t1-t
end sub

--
regards,
Tom Ogilvy

Rocky McKinley wrote in message
...
John, I tried your code and I get an error "Sub or Function not

defined."

--
Regards,
Rocky McKinley


"jaf" wrote in message
...
Hi Rocky,
Sub test()
t-timer
'lots of code
t1=timer
debug.print t1-t 'or msgbox t1-t
end sub


--

John

johnf202 at hotmail dot com


"Rocky McKinley" wrote in message
...
With the following code provided by this forum I'm able to pause a

sub
routine in thousanths of a second.
Is there a way to time how long it takes a sub routine to run in
thousanths
of a second?


Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub SleepOneSecond()
Sleep 1000
End Sub

--
Regards,
Rocky McKinley














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
sub routine Gord Dibben Excel Discussion (Misc queries) 0 November 13th 09 12:15 AM
VB routine to print to PDF? fedude Excel Worksheet Functions 4 March 15th 08 02:04 AM
simplifying routine KneeDown2Up New Users to Excel 5 January 4th 07 05:28 PM
Ending a routine art Excel Programming 1 October 27th 03 10:54 AM
Need VBA Routine John M. Lembo Excel Programming 0 July 13th 03 01:51 AM


All times are GMT +1. The time now is 11:28 AM.

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

About Us

"It's about Microsoft Excel"