Click here to Skip to main content
12,350,143 members (26,250 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET
Hi,
I am using following code to calculate time difference. I want to display the result in seconds. Please advise.

Dim myTime = DateTime.Parse("15:40:00 PM")
        Dim vrNowTime = DateTime.Parse(TimeOfDay)
        Dim result = vrNowTime - myTime
        Label1.Text = vrNowTime & "   " & myTime
        MsgBox(result.ToString)

Thanks
Posted 21-Dec-12 0:05am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Try:
MsgBox(result.TotalSeconds.ToString())
  Permalink  
Comments
ridoy 21-Dec-12 6:22am
   
+5
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Dim myTime = DateTime.Parse("15:40:00 PM")
Dim vrNowTime = DateTime.Parse(TimeOfDay)
Dim result = datediff( S,vrNowTime, myTime)
Label1.Text = vrNowTime & "   " & myTime
MsgBox(result.ToString)

Datediff is a brilliant function
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 21 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100