Results 1 to 5 of 5

Thread: msec - sec

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    UK
    Posts
    147

    msec - sec

    I know this should be simple but i have had a long day and i have lost the ability to think.

    I have a time value in mSecs. i want to convert this value into whole seconds and the remaining mSecs so i can display the values returned in a more user friendly manner.

    Thanks in advance
    Mik706

  2. #2
    Seconds = int(MSeconds / 1000)
    MSeconds = MSeconds - Seconds * 1000

    there ya go

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Originally posted by nareth
    Seconds = int(MSeconds / 1000)
    MSeconds = MSeconds - Seconds * 1000

    there ya go
    I'd use CLng rather than Ints as MSeconds can be really large.

    VB Code:
    1. Seconds = Clng(MSeconds \ 1000)
    2. MSeconds = MSeconds - Seconds * 1000

    Also by flipping the / to \ that will force it to use integer (whole number) division rather than floating point (which will return a decimal). This will make it more accurate.

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    i thought int removed decimals... what does int actually do? just convert to integer? i thought cint() did that

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Originally posted by nareth
    i thought int removed decimals... what does int actually do? just convert to integer? i thought cint() did that
    It rounds off, which can lead to innacurate results (it does some funky things when rounding.) The best way to remove decimals is to not have them in the first place.

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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