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

Time in Millisecond

Status
Not open for further replies.

pratibha14

Technical User
Mar 2, 2004
30
0
0
Hi,
I want time in milliseconds. One way that i came to knew is to use kernal32 as unmanaged code. Is there any other method known to anybody?
Thanks in anticipatiion.
Pratibha
 
>unmanaged code

Sounds like you want the VB.NET forum:forum796
 
Try something like this. Below is a wait routine that waits in msccs for an OLE action from another app.

Public Function wait_mSecs(Optional msecs = 1000#) As Double
'a milli second timer
Dim testtime As Double
Dim startTime As Double
Dim i As Long
Const TIMEOUT = 10000 '10 seconds
Const MAXITERATIONS = 1000000

If MSEC_WAIT_GLOBAL >= 0 Then msecs = MSEC_WAIT_GLOBAL

wait_mSecs = -1
i = 0
startTime = Timer
Do
i = i + 1
DoEvents
testtime = 1000 * (Timer - startTime)
Loop Until (testtime > msecs Or testtime > TIMEOUT Or i > MAXITERATIONS)

If testtime > TIMEOUT Then testtime = -1
If i > MAXITERATIONS Then testtime = -2
wait_mSecs = testtime
LogAction "wait_mSecs(): exit after " & wait_mSecs & " msecs"

Exitwait_mSecs:
Exit Function
Errorwait_mSecs:
GoTo Exitwait_mSecs
End Function
 
Thanks for ur suggestions.. but i think use of kernal32 to get it was better.
 
if this is a vb problem and not .net, you may want to check out QueryPerformanceCounter and QueryPerformanceFrequency API's

theres several examples of how to apply this on tek-tips.

good luck

If somethings hard to do, its not worth doing - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top