Results 1 to 6 of 6

Thread: An Easy Question for you guys.....

  1. #1

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

    An Easy Question for you guys.....

    Hey, I'm using VB and want to write code to convert seconds to min. and secs like this:

    220 secs. to xx:xx

    hope this makes sense

    any help appreciated

  2. #2
    Frenzied Member
    Join Date
    Jul 1999
    Location
    Huntingdon Valley, PA 19006
    Posts
    1,151

    Try Mod.

    Using the Mod Operator is one possibility. The following suggests, but is not VB code.

    40 = 220 Mod 60

    (220 - 40 ) / 60 = 3

    220 seconds = 3:40

    Does the above give you a clue?
    Live long & prosper.

    The Dinosaur from prehistoric era prior to computers.

    Eschew obfuscation!
    If a billion people believe a foolish idea, it is still a foolish idea!
    VB.net 2010 Express
    64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.

  3. #3

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

    where did you get 40?

    I understand some, but where did you get 40 in the first place?

  4. #4
    Addicted Member
    Join Date
    Feb 2001
    Location
    Classified
    Posts
    234
    Dident make much sense to me ither, until i looked it over a few more times. i basicaly took his stuff and converted it to vb

    Dim minutes, seconds As Integer
    Const TimeInSeconds = 220

    Private Sub Form_Load()
    seconds = TimeInSeconds Mod 60
    minutes = (TimeInSeconds - seconds) / 60
    MsgBox (minutes & ":" & seconds)
    End Sub
    My ICQ Status: (85634850)

    Seriously Sick Tshirts

  5. #5
    Frenzied Member
    Join Date
    Jul 1999
    Location
    Huntingdon Valley, PA 19006
    Posts
    1,151
    Hipopony66: The Mod Operator works on integer operands, and gives the remainder after dividing.

    200 / 60 = 3, with a remainder of 40

    Hence 40 = 220 Mod 60
    Live long & prosper.

    The Dinosaur from prehistoric era prior to computers.

    Eschew obfuscation!
    If a billion people believe a foolish idea, it is still a foolish idea!
    VB.net 2010 Express
    64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.

  6. #6
    Addicted Member
    Join Date
    Mar 2001
    Posts
    157
    You can use:
    minutes = TimeInSeconds \ 60
    instead of:
    minutes = (TimeInSeconds - seconds) / 60
    to find the no. of mins.

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