Results 1 to 4 of 4

Thread: convert minutes to seconds

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2020
    Posts
    32

    convert minutes to seconds

    Code:
    Debug.Print Val("62") \ 60 & ":" & Val("12") Mod 60
    this converts seconds to minutes

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: convert minutes to seconds

    What?????????????????????

    Try this instead....it will give the CORRECT answer, unlike whatever you posted!!!!

    Code:
    Dim iSeconds As Integer
    iSeconds = 62
    Debug.Print iSeconds \ 60 & ":" & Format(iSeconds Mod 60, "00")
    Last edited by SamOscarBrown; May 27th, 2020 at 09:32 PM.
    Sam I am (as well as Confused at times).

  3. #3
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: convert minutes to seconds

    If you want to convert minutes to seconds as your thread title says then you multiply by 60

    Seems like you are actually wanting to convert seconds to minutes and seconds instead which of course is quite different but given the brief and vague nature of the post I can only guess at what you really want.

  4. #4
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: convert minutes to seconds

    If it's seconds (converted to minutes), then there's the quite convenient, builtin:
    - TimeSerial(...) function ...which simply "adds up all passed parameters, with their appropriate multipliers"
    (so, more than 60 Seconds are allowed in the Seconds-param, but also negative Values in any of the params will work)

    It will return a VB-DateType from the calculated Sum, which you can then use to e.g.:
    - derive a Double-Value from it (in case you want to do math "on Minutes in Double-Format)
    - or (for String-conversion) you can pass the TimeSerial-DateType-ReturnValue to the Format-Function like this

    Debug.Print Format(TimeSerial(0, 0, 62), "hh:mm:ss")

    HTH

    Olaf

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