Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get milliseconds

Status
Not open for further replies.

developer155

Programmer
Joined
Jan 21, 2004
Messages
512
Location
US
What is a good VB function that would allow me to get milliseconds of the server time. Looks like Time function returns hh/mm/ss. Another one I found is GetLocalTime, but thats an API fun and I am not sure how to use it. I am sure there is a simpler way

thanks!!!
 
Do a keywoed search for 'millisecond' in this forum.

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
thanks!. I found this:
Public Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Public Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type

but should I copy that code into my code? That looks like a seoarate function, but I get an error when I try to run the code. Is there any thing specific that needs to be done?
 
Either put them in a module of change them from Public to Private.

Swi
 
Hi,

If you want TIME in miliseconds...
[tt]
ms = Time * 24 * 3600 * 1000
[/tt]
or am I missing something?

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
But that wouldn't let you do millisecond resolution time calculations (which windows isn't particularly good at AFAIK anyway).

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
Put your code as above into a BAS module. Then when you want to use it:

Dim myTime as SYSTEMTIME
getsystemtime myTime
debug.Print myTime.wMilliseconds

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
But be aware that the resolution of GetSystemTime is limited to the tick rate of the system timer, which is ~55ms for W98/Me, ~10ms for Nt4, and 10 or 15ms for XP.

There are ways to get actual millisecond (and better) resolution timing on Windows; we've covered most of the methods on a number of occassions in this forum, A keyword search should find them
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top