time in vb.net

I just want to know what is the minimum amount of time difference we can measure by using vb.net
its like i send a packet and then receive it.
i want to calculate the time difference. i guess it mightl be 1 millisecond or lower.

is their any way to get the time difference less than 1 milli second


thanx in advance
---prashanth
prashanth_gurijalaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

iboutchkineCommented:
I think that minimum is a tick

    Dim T1, T2 As System.DateTime

        T1 = Now
'do something
        T2 = Now
        MsgBox("It took " & ((T2.Ticks - T1.Ticks) / 10000).ToString & " msecs to sort array")
0
rdrunnerCommented:
you could try "timer()"

This will allow you to get the seconds passed since midnight... But i dont know whats the smalles value for it
0
rdrunnerCommented:
Now will only return down to the second :(
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

acharbonneauCommented:
There is the tick, which is 100 nanoseconds
0
GohdanTheMoblinCommented:
Looking over the documentation for the DateTime.Now property, it seems that the resolution depends on the System timer.

DateTime.Now: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatetimeclassnowtopic.asp

This means that past NT 3.5, you only have 10ms of guaranteed resolution.  An alternative is the Environment.TickCount property, but it claims it is derived from the System Timer as well and additionally its resolution "cannot be less than 500 milliseconds", so DateTime.Now seems best.

Environment.TickCount: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemenvironmentclasstickcounttopic.asp

To measure time as accurately as possible, use the TimeSpan class and its properties.  Here's a simple example that shows the number of milliseconds it takes to perform an operation:

*BEGIN CODE*
    Dim startTime as DateTime
    Dim endTime as DateTime
    Dim ts as TimeSpan

   startTime = DateTime.Now
   DoTheTaskYouAreTiming()
   endTime = DateTime.Now

   ts = endTime.Subtract(startTime)

    MessageBox.Show("Took " & ts.totalMilliseconds & " milliseconds.")
*END CODE*
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
prashanth_gurijalaAuthor Commented:
thanx for the info guys,
i got some information from here which can measure in microseconds,
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q172/3/38.asp&NoWebContent=1

and ticks is not gonna help as its again rounds to milliseconds....

and all system.timers rounds to accuracy of 10 ms

any way thanx for all the infor guys,
prashanth
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.