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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System time in VB

Status
Not open for further replies.

redoctober

Programmer
Oct 25, 2000
37
CA
Quick question, is it possible to get a system time in VB with precesion to a millisecond? Time and Now give you time only to a second but i need better resolution.

Thanks.
 
You could try the GetSystemTime API

Code:
Public Declare Sub GetSystemTime Lib "kernel32" Alias "GetSystemTime" (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
 
Probably worth pointing out that whilst SytemTime has a member called wMilliseconds it is not actually accurate to the millisecond. See my comments in thread222-799934 for an overview of why not.
 
Yup. The system clock in Windows is only accurate to 30 milliseconds or so.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top