please help me get the system's time (with milliseconds) i need it to calculate the Soap request and response time in my SOAP project. i tried to use timer but the problem is, whenever i'm invoking a method.... the timer gets stuck along with the process, meaning it always returns .01 millisecond.... .. timer hangs with my pc..... i need to get the system time (with milliseconds) before and after calling the webservice then compute for the difference..... PLEASE HELP ME GUYS THIS THING'S IMPORTANT TO ME !! Thanx a lot !!!!!
Help, get system time with milliseconds without Timer control
Collapse
X
-
-
Originally posted by jeffbroodwarplease help me get the system's time (with milliseconds) i need it to calculate the Soap request and response time in my SOAP project. i tried to use timer but the problem is, whenever i'm invoking a method.... the timer gets stuck along with the process, meaning it always returns .01 millisecond.... .. timer hangs with my pc..... i need to get the system time (with milliseconds) before and after calling the webservice then compute for the difference..... PLEASE HELP ME GUYS THIS THING'S IMPORTANT TO ME !! Thanx a lot !!!!!
use Format(Now, "HH:mm:ss:m s") -
Comment
-
Solved....
'Declarations :
-----------------------------------------------------------------------------------------------------------
Option Explicit
Private 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 Declare Sub GetSystemTime Lib "kernel32" _
(lpSystemTime As SYSTEMTIME)
------------------------------------------------------------------------------------------------------------
'Function :
------------------------------------------------------------------------------------------------------------
Public Function TimeToMilliseco nd() As String
Dim sAns As String
Dim typTime As SYSTEMTIME
On Error Resume Next
GetSystemTime typTime
sAns = Hour(Now) & ":" & Minute(Now) & ":" & Second(Now) & _
":" & typTime.wMillis econds
TimeToMilliseco nd = sAns
End FunctionComment
-
guess so.... but why? i mean it goes with vb's format function right? why will it be wrong???... hmm... can you test the code that i've posted? perhaps you can help me decide what's the correct one.... and please explain to me why your post is wrong. i tested it, it's obviously wrong but what made it wrong? thanx....Comment
-
no, i told the post which i had post is wrongOriginally posted by jeffbroodwarguess so.... but why? i mean it goes with vb's format function right? why will it be wrong???... hmm... can you test the code that i've posted? perhaps you can help me decide what's the correct one.... and please explain to me why your post is wrong. i tested it, it's obviously wrong but what made it wrong? thanx....Comment
-
Originally posted by hariharanmcause Format(Now, "HH:mm:ss:m s")
Format(Now, "HH:mm:ss:m s")
is incorrect..... for some reason the ms is not reconised by visual basic...
I've not had time to look into it, but do simple test
you will see the last 3 digits are actully seconds.....Code:Private Sub Command1_Click() MsgBox Format(Now, "HH:mm:ss:ms") End Sub
my is "3" then the current seconds digit(s)
the API GetSytemTime Works best for current system time.... API's are always prefferedComment
-
Hope this is what you wanted:
Cheers!Code:Public Sub DoWork() Dim startDt as Date = Now() ' Do you work here Dim endDt as Date = Now() Dim tm as long = DateDiffMs(startDt, endDt) End Sub Public Shared Function DateDiffMs(ByVal startDt As Date, ByVal endDt As Date) As Long Dim ms As Long = DateDiff(DateInterval.Second, startDt, endDt) * 1000 If (endDt.Millisecond - startDt.Millisecond) < 0 Then ms += 1000 - (startDt.Millisecond - endDt.Millisecond) Else ms += (endDt.Millisecond - startDt.Millisecond) End If Return ms End FunctionComment
-
This actually works. I have been looking for a solution to this sort of problem for some time. Funny that I never came across the "Date.Milliseco nd" bit, it was there all the time...Originally posted by GoHokies95Hope this is what you wanted:
Code:Public Sub DoWork() Dim startDt as Date = Now() ' Do you work here Dim endDt as Date = Now() Dim tm as long = DateDiffMs(startDt, endDt) End Sub Public Shared Function DateDiffMs(ByVal startDt As Date, ByVal endDt As Date) As Long Dim ms As Long = DateDiff(DateInterval.Second, startDt, endDt) * 1000 If (endDt.Millisecond - startDt.Millisecond) < 0 Then ms += 1000 - (startDt.Millisecond - endDt.Millisecond) Else ms += (endDt.Millisecond - startDt.Millisecond) End If Return ms End Function
Thanks very much.Comment
Comment