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 !!!!!
8 43963
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 !!!!!
use Format(Now, "HH:mm:ss:ms")
use Format(Now, "HH:mm:ss:ms")
sorry, the above post is worng
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 TimeToMillisecond() As String
Dim sAns As String
Dim typTime As SYSTEMTIME
On Error Resume Next
GetSystemTime typTime
sAns = Hour(Now) & ":" & Minute(Now) & ":" & Second(Now) & _
":" & typTime.wMilliseconds
TimeToMillisecond = sAns
End Function
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....
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....
no, i told the post which i had post is wrong
use Format(Now, "HH:mm:ss:ms")
Format(Now, "HH:mm:ss:ms")
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 - Private Sub Command1_Click()
-
MsgBox Format(Now, "HH:mm:ss:ms")
-
End Sub
you will see the last 3 digits are actully seconds.....
my is "3" then the current seconds digit(s)
the API GetSytemTime Works best for current system time.... API's are always preffered
Hope this is what you wanted: -
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
-
Cheers!
Hope this is what you wanted: -
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
-
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.Millisecond" bit, it was there all the time...
Thanks very much.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: curious |
last post by:
I am new to VB.NET and I need help in using timer control. Here is
the scenario. I have 3 labels (label 1, label2, label 3), and a start
button, all vertically aligned on the form.
Using a...
|
by: William Bub |
last post by:
Is there an accurate way to create a "stopwatch" good to 1/10 of a second?
I'm not sure if I should use the timer control, or some way to access the
computer timer. I found the following site...
|
by: David |
last post by:
Hi There!
I'm using Timer control to record how long my application perform certain
tasks.
However, apparently Timer control is not doing its' job (i.e. Not firing
Tick event) while my...
|
by: Partho Choudhury |
last post by:
Hi all:
I need to add a snippet which access the system time (upto atleast
milliseconds) using ANSI std. C++. I cannot use MFC and Win32 APIs in
my program for now for various reasons. Is there...
|
by: marcus |
last post by:
Is their a method in c++ or c that gives me the system time in
milliseconds or higher resolution? I need it to be platform
independent. Today I use timeGetTime which is windows specific.
thanks
|
by: Steve |
last post by:
I am working on a emulator and need to have time based events. I've tried
to use the timer control and discovered that it runs waaaaaaay slow. I set
the tick frequency to 1, then in the tick...
|
by: abhishek007p |
last post by:
HI,
i am using visual web developer for .net 2.0.
does .NET 2.0 comes with a timer control, i was unable to find it in
the IDE, where is it ?
thanks,
Abhishek
|
by: Steve |
last post by:
Hi All
I am using VB.net 2008 and use timer controls within my applications
Question
Does the code in a Timer control.tick event run on a different thread to the
main Application thread (UI...
|
by: neelsfer |
last post by:
I need to add milliseconds to this finishtime of race
!!! = Format(Now(), "General Date")
Start code for race also in milliseconds
!!! = Format(Now(), "General Date")
I will then subtract it...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| | |