Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Problem with hundredth of seconds

Hello.
I use the following code to get an executing time in cell A1 :

HeureDebut = time()
code......
HeureFin = time()
Duree = HeureFin - HeureDebut
Range("A1").value = Duree

I get numbers such as 0.000173611111111138 in standard number format.
If I use hh:mm:ss.00 as a mask, I dont get but zeroes after the seconds :
00:15:00
I use ROUNDED(0.000173611111111138,6) to get 00:15:03.
This doesn't affect the calculations, only the display.
Why cant Excel use the numbers provided by VBA ?
Thanks in advance.
Daniel


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Problem with hundredth of seconds

Time() returns a number already rounded to seconds.

Try a higher resolution timer via API:


Declare Function timeGetTime Lib "winmm.dll" () As Long

Sub test()
Dim lng As Long

lng = timeGetTime()
Range("A1:IV60000").Value = 1 'example to create delay
lng = timeGetTime() - lng

MsgBox lng & " milliseconds"
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Daniel" wrote in message
...
Hello.
I use the following code to get an executing time in cell A1 :

HeureDebut = time()
code......
HeureFin = time()
Duree = HeureFin - HeureDebut
Range("A1").value = Duree

I get numbers such as 0.000173611111111138 in standard number format.
If I use hh:mm:ss.00 as a mask, I dont get but zeroes after the seconds :
00:15:00
I use ROUNDED(0.000173611111111138,6) to get 00:15:03.
This doesn't affect the calculations, only the display.
Why cant Excel use the numbers provided by VBA ?
Thanks in advance.
Daniel




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Problem with hundredth of seconds

Thanks, Rob, you made it quite clear.
Daniel
"Rob van Gelder" a écrit dans le
message de news: ...
Time() returns a number already rounded to seconds.

Try a higher resolution timer via API:


Declare Function timeGetTime Lib "winmm.dll" () As Long

Sub test()
Dim lng As Long

lng = timeGetTime()
Range("A1:IV60000").Value = 1 'example to create delay
lng = timeGetTime() - lng

MsgBox lng & " milliseconds"
End Sub


--
Rob van Gelder -
http://www.vangelder.co.nz/excel


"Daniel" wrote in message
...
Hello.
I use the following code to get an executing time in cell A1 :

HeureDebut = time()
code......
HeureFin = time()
Duree = HeureFin - HeureDebut
Range("A1").value = Duree

I get numbers such as 0.000173611111111138 in standard number format.
If I use hh:mm:ss.00 as a mask, I dont get but zeroes after the seconds :
00:15:00
I use ROUNDED(0.000173611111111138,6) to get 00:15:03.
This doesn't affect the calculations, only the display.
Why cant Excel use the numbers provided by VBA ?
Thanks in advance.
Daniel






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default Problem with hundredth of seconds

Use the following format:
Dim ztime#
ztime = Val(".000173611111111138")
MsgBox Format(ztime, "hh:mm:ss.ss")

Daniel wrote:
I use the following code to get an executing time in cell A1 :

HeureDebut = time()
code......
HeureFin = time()
Duree = HeureFin - HeureDebut
Range("A1").value = Duree

I get numbers such as 0.000173611111111138 in standard number format.
If I use hh:mm:ss.00 as a mask, I dont get but zeroes after the seconds :
00:15:00
I use ROUNDED(0.000173611111111138,6) to get 00:15:03.
This doesn't affect the calculations, only the display.
Why cant Excel use the numbers provided by VBA ?
Thanks in advance.
Daniel




----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default Problem with hundredth of seconds

My post is BS. Sorry.

Dave wrote:
MsgBox Format(ztime, "hh:mm:ss.ss")




----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
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
race results in minute:seconds.hundredth sec Chris Excel Discussion (Misc queries) 3 June 2nd 10 05:31 AM
Why are sometimes seconds not shown in cell? timestamp format problem Claudia d'Amato Excel Discussion (Misc queries) 1 February 19th 10 11:00 PM
How do I change percentage function to less than a hundredth? Georgia New Users to Excel 1 January 23rd 06 04:52 PM
Excel should format time down to the hundredth/sec. John Krick Excel Discussion (Misc queries) 3 November 28th 05 09:23 PM
EXCEL - I need to compare times to the hundredth of a second savery422 Setting up and Configuration of Excel 1 June 20th 05 06:32 PM


All times are GMT +1. The time now is 05:41 PM.

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"