Results 1 to 3 of 3

Thread: double to min:sec - Solved

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2007
    Posts
    2

    double to min:sec - Solved

    I'm trying to convert time in millisecunds (as double) to time in minutes and seconds. Does anyone have an easy way of doing this?
    Last edited by djem; Jan 18th, 2007 at 12:21 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: double to min:sec

    Create a TimeSpan using the FromMilliseconds method, then use the TotalMinutes and Seconds properties.
    VB Code:
    1. Dim milliseconds As Integer 'Store number of milliseconds here.
    2. Dim time As TimeSpan = TimeSpan.FromMilliseconds(milliseconds)
    3. Dim timeString As String = String.Format("{0:00}:{1:00}", Convert.ToInt32(Math.Floor(time.TotalMinutes)), time.Seconds)
    4.  
    5. MessageBox.Show(timeString)
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2007
    Posts
    2

    Re: double to min:sec

    thanks, that was exactly what I where after.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width