Results 1 to 5 of 5

Thread: Can this be condesed to one line???

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    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?

  2. #2
    Addicted Member
    Join Date
    Feb 2001
    Location
    Classified
    Posts
    234
    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
    My ICQ Status: (85634850)

    Seriously Sick Tshirts

  3. #3
    Addicted Member
    Join Date
    Feb 2001
    Location
    Classified
    Posts
    234
    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!)
    My ICQ Status: (85634850)

    Seriously Sick Tshirts

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  5. #5
    Addicted Member
    Join Date
    Feb 2001
    Location
    Classified
    Posts
    234

    Smile 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
    My ICQ Status: (85634850)

    Seriously Sick Tshirts

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