473,799 Members | 2,761 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help, get system time with milliseconds without Timer control

jeffbroodwar
118 New Member
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 !!!!!
Feb 20 '07 #1
8 44062
hariharanmca
1,977 Top Contributor
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:m s")
Feb 20 '07 #2
hariharanmca
1,977 Top Contributor
use Format(Now, "HH:mm:ss:m s")
sorry, the above post is worng
Feb 20 '07 #3
jeffbroodwar
118 New Member
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 Function
Feb 20 '07 #4
jeffbroodwar
118 New Member
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....
Feb 20 '07 #5
hariharanmca
1,977 Top Contributor
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
Feb 20 '07 #6
mayhem
1 New Member
use 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

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. MsgBox Format(Now, "HH:mm:ss:ms")
  3. 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
Mar 13 '07 #7
GoHokies95
3 New Member
Hope this is what you wanted:
Expand|Select|Wrap|Line Numbers
  1. Public Sub DoWork()
  2.      Dim startDt as Date = Now()
  3.  
  4.      ' Do you work here
  5.  
  6.      Dim endDt as Date = Now()
  7.  
  8.      Dim tm as long = DateDiffMs(startDt, endDt)
  9.  
  10.   End Sub
  11.  
  12.  
  13.   Public Shared Function DateDiffMs(ByVal startDt As Date, ByVal endDt As Date) As Long
  14.     Dim ms As Long = DateDiff(DateInterval.Second, startDt, endDt) * 1000
  15.     If (endDt.Millisecond - startDt.Millisecond) < 0 Then
  16.       ms += 1000 - (startDt.Millisecond - endDt.Millisecond)
  17.     Else
  18.       ms += (endDt.Millisecond - startDt.Millisecond)
  19.     End If
  20.     Return ms
  21.   End Function
  22.  
Cheers!
Mar 13 '07 #8
kaihora
1 New Member
Hope this is what you wanted:
Expand|Select|Wrap|Line Numbers
  1. Public Sub DoWork()
  2.      Dim startDt as Date = Now()
  3.      ' Do you work here
  4.      Dim endDt as Date = Now()
  5.      Dim tm as long = DateDiffMs(startDt, endDt)
  6. End Sub
  7.  
  8. Public Shared Function DateDiffMs(ByVal startDt As Date, ByVal endDt As Date) As Long
  9.     Dim ms As Long = DateDiff(DateInterval.Second, startDt, endDt) * 1000
  10.     If (endDt.Millisecond - startDt.Millisecond) < 0 Then
  11.       ms += 1000 - (startDt.Millisecond - endDt.Millisecond)
  12.     Else
  13.       ms += (endDt.Millisecond - startDt.Millisecond)
  14.     End If
  15.     Return ms
  16.   End Function
  17.  
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...

Thanks very much.
Mar 14 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
23943
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 timer control with interval value of 3000, i.e 3 second, I want to accomplish the following: - Initially, only START button is visible to the user, i.e the 3 labels are set to be invisible. - When click on START button, the button disappear and...
4
31217
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 http://searchvb.techtarget.com/tip/1,289483,sid8_gci535495,00.html which has the following: > Want to really get down to instants? This tip from reader Phil Lenoir tells you how. >...
3
1869
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 application is busy. So even if my application took 2 mins, the label that is used to show the number of seconds elapsed will still say "2 seconds".
10
34398
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 something like this in ANSI C++ which allows access up to milliseconds. I know that time.h and CTime allow access up to the second level, but I need to work in the msec level. Any help will be appreciated.
8
6796
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
6
2225
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 event I update a label on my form, nothing else. just counting in my head I have determined that it take roughly 14 seconds to get through 1000 ticks or 1 second of the timer. This really surprises me. I haven't even done any processing yet and...
1
1426
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
3
3889
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 Thread)? In some of the timers I update some UI controls e.g statusbar.labels and I
16
38534
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 from the start time and get a result in milliseconds RacingTime: Format(-,"hh:nn:ss") Any suggestions on how this can be accomplished?
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10252
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9073
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7565
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.