Click to See Complete Forum and Search --> : Time. . . is on the esscence
Drinky
Jan 3rd, 2000, 07:52 AM
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
wizard_03@hotmail.com
Drinky
Jan 3rd, 2000, 07:53 AM
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
wizard_03@hotmail.com
ShadowCrawler
Jan 3rd, 2000, 09:37 AM
Email me the C++ code, I'll take a look at it and see what needs to be converted to VB.
craigkovatch@compuserve.com
------------------
(¯`·.¸¸.·´¯`·->ShadowCrawler<-·´¯`·.¸¸.·´¯)
Teenage Programmer
Visual Basic, HTML, C++, JavaScript
http://welcome.to/X12Tech
Email: craigkovatch@compuserve.com
ICQ#: 9872708 (http://wwp.mirabilis.com/9872708)
Bob Baddeley
Jan 3rd, 2000, 09:46 AM
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
Drinky
Jan 4th, 2000, 01:07 AM
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
wizard_03@hotmail.com
Drinky
Jan 4th, 2000, 01:14 AM
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:
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
wizard_03@hotmail.com
[This message has been edited by Drinky (edited 01-04-2000).]
Bob Baddeley
Jan 4th, 2000, 01:25 PM
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:
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 :D
bob
Drinky
Jan 7th, 2000, 10:08 AM
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
wizard_03@hotmail.com
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.