Wrox Programmer Forums
|
Visual Basic 2008 Essentials If you are new to Visual Basic programming with version 2008, this is the place to start your questions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2008 Essentials section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 15th, 2009, 08:31 PM
Registered User
 
Join Date: Feb 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Time

My goal is to obtain two times from a user and calculate the difference between those two.

The format I want to use is: 00:00.00 => 01:48.4 (1 minute and 48.4 seconds.)

What is the code for this simple calculation and what are the variable declarations?

Thanks to any who can help me.

I submitted this in the beginners section but appears to be dead in there
 
Old February 16th, 2009, 12:46 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

The best way to do this would be to use a TimeSpan. After you get the result you can format it any way you like it.

http://articles.techrepublic.com.com...1-5760752.html

hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
 
Old February 16th, 2009, 11:46 PM
jomet
Guest
 
Posts: n/a
Default

Code:
        Dim t1 As Date = Date.Now
        Dim t2 As Date = Date.Now.AddSeconds(108.4)
        Dim ts As TimeSpan = t2 - t1
        MessageBox.Show(ts.Minutes.ToString() & ":" & ts.Seconds.ToString() & "." & ts.Milliseconds.ToString())







Similar Threads
Thread Thread Starter Forum Replies Last Post
synchronizing pocket pc time with desktop time bobbyrayudu83 C# 1 April 2nd, 2011 04:28 AM
Time Shift time in minus time out lechalas Beginning VB 6 1 August 11th, 2008 01:56 PM
time zone & day light time rajn ASP.NET 1.0 and 1.1 Professional 0 August 7th, 2007 05:02 PM
Using xs:time to generate time in desired format krayan001 XSLT 0 June 27th, 2005 04:28 PM
recordcount some time return -2 or sum time -1 pradeep1976 BOOK: Beginning ASP 3.0 1 April 7th, 2005 08:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.