Results 1 to 8 of 8

Thread: Time. . . is on the esscence

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 1999
    Location
    N/A, N/A, England
    Posts
    21

    Post

    My brain stopped working this afternoon. . . :-(

    I can't figure out how to change a number of milliseconds into day's minutes hours and seconds.

    for example 5400 milliseconds = 0 Days, 1 Hours, 30 Mins, 00 Seconds

    Got a piece of code that does this in C++ that i wrote ages ago but for some odd reason it doesn't seem to work.


    ------------------
    Third year Software Engineering Student.

    On placement at the University of Manchester
    playing with expensive cool things...
    http://drinky.u4l.com
    [email protected]



  2. #2

    Thread Starter
    Junior Member
    Join Date
    May 1999
    Location
    N/A, N/A, England
    Posts
    21

    Post

    Doh! the topic title should be "Time. . . is of the esscence"

    told u my brain stoped working :-)

    ------------------
    Third year Software Engineering Student.

    On placement at the University of Manchester
    playing with expensive cool things...
    http://drinky.u4l.com
    [email protected]



  3. #3
    Member
    Join Date
    Jan 1999
    Location
    Gig Harbor, WA, USA
    Posts
    48

    Post

    Email me the C++ code, I'll take a look at it and see what needs to be converted to VB.

    [email protected]

    ------------------
    (¯`·.¸¸.·´¯`·->ShadowCrawler<-·´¯`·.¸¸.·´¯)
    Teenage Programmer
    Visual Basic, HTML, C++, JavaScript

    http://welcome.to/X12Tech
    Email: [email protected]
    ICQ#: 9872708

  4. #4
    Hyperactive Member
    Join Date
    Sep 1999
    Posts
    305

    Post

    I must be missing something. if there are 1000 milliseconds in a second, then 5400 milliseconds is 5.4 seconds, not 1.5 hours. but some quick math in my head indicates that 5400 seconds = 1.5 hours, or 5,400,000 milliseconds = 1.5 hours.

    So milliseconds/1000 = seconds

    milliseconds/60,000=minutes

    milliseconds/3,600,000=hours

    milliseconds/(24*3,600,000)=days (I didn't want to do that one in my head)

    Am I right, or what? It seems like my brain is on right, but then, if it wasn't, how would I know? Anyway, I hope this helps and I hope you find your brain.

    bob

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 1999
    Location
    N/A, N/A, England
    Posts
    21

    Post

    Like I said bad day :-)

    5400 seconds is 1.5 hours :-)
    you are indeed correct.

    ------------------
    Third year Software Engineering Student.

    On placement at the University of Manchester
    playing with expensive cool things...
    http://drinky.u4l.com
    [email protected]



  6. #6

    Thread Starter
    Junior Member
    Join Date
    May 1999
    Location
    N/A, N/A, England
    Posts
    21

    Post

    How ever bob. . .

    what I want is clock format time. . .
    your solution will give me.

    5,400,000 Milliseconds = 5,400 Seconds, = 90 Minutes = 1.5 hours = 0.0625 Days

    Which is not what I want.

    I want a function that when given a figure of 5400000 milliseconds will return

    0 days 1:30:00

    The C++ code I have for this doesn't do the days part and only converts from seconds (it is but a simple matter to get seconds from milliseconds) but i diddn't need that at the time. Here it is:

    Code:
    void get_time_from_seconds(long time, int& h, int& m, int& s)
    {
        int tMins = time / 60;
    	h = ( tMins / 60) % 24;
    	m = tMins % 60;
    	s = time % 60;
    }
    ------------------
    Third year Software Engineering Student.

    On placement at the University of Manchester
    playing with expensive cool things...
    http://drinky.u4l.com
    [email protected]




    [This message has been edited by Drinky (edited 01-04-2000).]

  7. #7
    Hyperactive Member
    Join Date
    Sep 1999
    Posts
    305

    Post

    Then how about something simple like:

    1.) new program

    2.) add a timer (at 1000 interval) and a text box

    3.) put this code in:

    Code:
    Dim S
    Dim M
    Dim H
    Dim D
    
    
    Private Sub Form_Load()
    S = 0
    M = 0
    H = 0
    D = 0
    End Sub
    
    Private Sub Timer1_Timer()
    S = S + 1
    If S >= 60 Then
    S = 0
    M = M + 1
    Else
    End If
    If M >= 60 Then
    M = 0
    H = H + 1
    Else
    End If
    If H >= 24 Then
    H = 0
    D = D + 1
    Else
    End If
    Text1.Text = D & " days " & H & ":" & M & " " & S
    End Sub
    4.) run it.

    I'll admit it wasn't simple, and it took me a fair bit of time to figure it out, and it probably isn't what you want, so I'll just go cry now. Sigh

    bob

  8. #8

    Thread Starter
    Junior Member
    Join Date
    May 1999
    Location
    N/A, N/A, England
    Posts
    21

    Post

    Cheers Bob, I'll give it a whirl

    ------------------
    Third year Software Engineering Student.

    On placement at the University of Manchester
    playing with expensive cool things...
    http://drinky.u4l.com
    [email protected]



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