|
-
Oct 1st, 2001, 01:37 AM
#1
Thread Starter
Fanatic Member
Can this be condesed to one line???
aduration = Int(ms / 1000)
bduration = aduration Mod 60 'calculates secs
cduration = (aduration - bduration) / 60 'calculates mins
Duration = cduration & ":" & bduration
This code uses the Mod function to convert seconds to Minutes and seconds. However, I need all of this in just on line for what duration =.... can this be condensed?
-
Oct 1st, 2001, 03:13 AM
#2
Addicted Member
Dont mind me, im still awake at 6am (no sleep in 2 days) and im being powered by a bottle of CocaCola...
I dident test this out, but i think (if the coca cola is doin its job) that this will do it.
Duration = (int(ms / 1000) - (int(ms / 1000) mod 60) / 60) & ":" & int(ms / 1000) mod 60
-
Oct 1st, 2001, 03:16 AM
#3
Addicted Member
Duration = (int(ms / 1000) - (int(ms / 1000) mod 60) / 60) & ":" & (int(ms / 1000) mod 60)
Same thing, but i put a cuple extra brackets in their. Probably wont effect the outcome, but just for the hell of it... (and an extra post on my score!)
-
Oct 1st, 2001, 03:33 AM
#4
transcendental analytic
Why? Your original solution is much more performnace efficient.
If you want best perfomance, the ultimate solution is:
aduration = ms \ 1000
bduration = aduration Mod 60 'calculates secs
cduration = aduration \ 60 'calculates mins
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 1st, 2001, 03:37 AM
#5
Addicted Member
Bracket Boy
well, with my marks in my math class, im just glad it actualy worked... lol
To the starter of the thread... if this post was related to your other post, heres the solution to it...
(damn, i should lay off the brackets ;D (yes, i know i use them too much (heh (its how i think things thru easyer))))
Private Sub Form_Load()
MsgBox (((TimeInSeconds - (TimeInSeconds Mod 60)) / 60) & ":" & (TimeInSeconds Mod 60))
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|