Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

marking time in vb

i want to mark time to as much precision
as possible.  how do i do it in vb?

thanks.
senardji
0
senardji
Asked:
senardji
1 Solution
 
gafftechCommented:
you can use Getsystemtime
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
Private Sub Command1_Click()
Dim x As SYSTEMTIME
Dim stime As String
GetSystemTime x
Me.Text1.Text = x.wHour & ":" & x.wMinute & ":" & x.wSecond & ":" & x.wMilliseconds
End Sub
0
 
mark2150Commented:
You asked this same Q twice.

You can't measure time more precisely than the 18.2hz (55ms) timer tick without special hardware.

M
0
 
mark2150Commented:
You asked this same Q twice.

You can't measure time more precisely than the 18.2hz (55ms) timer tick without special hardware.

M
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Brendt HessSenior DBACommented:
The 18.2hz limit is not a problem anymore.  The system has more accurate timing than that available.

Here's a link to some examples of 1ms precision timers:

http://www.thescarms.com/vbasic/Timer.htm
0
 
Brendt HessSenior DBACommented:
The 18.2hz limit is not a problem anymore.  The system has more accurate timing than that available.

Here's a link to some examples of 1ms precision timers:

http://www.thescarms.com/vbasic/Timer.htm
0
 
st_steveCommented:
use TickCount API....it's an easy way to get the time information..and more accurate than timer control...but not too difficult to declare
0
 
senardjiAuthor Commented:
thanks all!
0
 
mark2150Commented:
bhess1,

You should have read the 'fine print'... from the page you cite:

Code based timers are still subject to the operating system's load and preemptive multitasking nature.  For best results, close all unnecessary applications.

Guess what? You simply cannot *guarentee* tight timing with software based timers. You *have* to use hardware as a timing reference if you need *ACCURATE, CONSISTENT, RELIABLE* timing! And the PC simply doesn't have that. If you need a steady "heartbeat" timer that doesn't vary, doesn't jitter, doesn't slop, the only thing you can use on a standard PC is the 18.2Hz time of day clock. If you need tighter times than that you'll have to add hardware.

M
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now