How to get time difference in milliseconds in VB6

Visual Basic Topics
Post Reply
User avatar
Saman
Lieutenant Colonel
Lieutenant Colonel
Posts: 828
Joined: Fri Jul 31, 2009 10:32 pm
Location: Mount Lavinia

How to get time difference in milliseconds in VB6

Post by Saman » Thu Mar 22, 2012 1:52 am

There is no direct method to get time difference in milliseconds in VB6. This is required for profiling functions where difference in seconds is not enough. Here is how you could do that.

Code: Select all

Private Declare Function GetTickCount Lib "kernel32" () As Long ‘For timer

Code: Select all

Dim dtStart As Long
Dim dtEnd As Long
Dim result As Long
Dim i As Integer

dtStart = GetTickCount
'Function to profile
dtEnd = GetTickCount

result = dtEnd – dtStart
MsgBox “Duration is ” & result & ” milliseconds.”
Post Reply

Return to “Visual Basic Programming”