Results 1 to 12 of 12

Thread: format GetTickTime

  1. #1

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125

    format GetTickCount time

    I have this code in a module:
    Code:
    Public Declare Function GetTickCount Lib "kernel32" () As Long
    Dim lRtrn As Long
    and this in a timer on the form:
    Code:
    lRtrn = GetTickCount
    Label1.Caption = lRtrn
    how can I format it to look like time? ie hh:mm:ss? I've tried the format(lRtrn, "hh:mm:ss"), but it says there is an overflow. What can I do to format it?

    Thanks
    <removed by admin>

  2. #2
    Guest
    mm = month
    nn = minutes

    format(lRtrn, "hh:nn:ss")

  3. #3

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    I still get an overflow. Is there a function that changes a number into time format? (hh:nn:ss). The number is counting up in milliseconds. The format of the number is below:
    Code:
    458962
    | | |_____ milliseconds
    | |_______ seconds
    |_________ minutes
    The only problem with this is that when the seconds get to 60 it goes to 61 instead of adding 1 to the minutes and going back to zero. Is there a way to format this? Thanks.
    <removed by admin>

  4. #4
    Addicted Member Ramandeep's Avatar
    Join Date
    Feb 2000
    Posts
    158
    To get minutes you devide it by 60000 (1000 = 1sec). You can then devide that further to get min & sec or somthing.

  5. #5
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Description & Usage
    GetTickCount determines how much time has elapsed since Windows was last started. The time is measured in milliseconds, although the actual resolution of the function's output depends on that of the system timer itself. Therefore, it may not be perfectly accurate to the millisecond. Because of the limitations of the 32-bit integer data type, the reported elapsed time wraps back to zero after about 49.7 days of continuous operation.
    Code:
    dim x,y,z
    x = GetTickCount / 1000  ' = Seconds
    y = x / 60  '= minuites
    z = y / 60  '=hours
    What are you trying to accomplish?
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  6. #6

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    I'm learning how to use visual basic, and saw a post that had the GetTickCount call in it. I just wanted to explore it so I made a program that runs next to the system clock that tells how long the computer has been up. When it gets to a certain time, I want a window to popup asking the user if they would like to reboot to refresh their resources. (cause in windows, it crashes if you leave it up too long.)
    <removed by admin>

  7. #7
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    time conversion

    What does GetTickCount return number of millisecond from the 24 hour clock?

    Is it possible to get todays date in seconds from this function.?

  8. #8

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    You can't get the date in seconds because it counts the amout of time that the computer has been running.
    <removed by admin>

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You use Date$ function to return the current date, Time$ to return the current time, Now to return the current Datetime.
    You can also use Gettickcount to add the extra milliseconds up to the datetime:
    Code:
    Now & "." & gettickcount mod 1000&
    And also you can convert the gettickcount time to hh:mm:ss format by using timeserial:
    Code:
    Timeserial(0,0,Gettickcount\1000&) & "." & gettickcount mod 1000&
    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.

  10. #10
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    calls

    Could someone tellme where calls like this go?

    Private Const REG_OPTION_NON_VOLATILE = 0
    Private Const REG_SZ As Long = 1
    Private Const REG_BINARY = 3
    Private Const REG_DWORD As Long = 4

    Private Const READ_CONTROL = &H20000
    Private Const SYNCHRONIZE = &H100000
    Private Const KEY_ALL_ACCESS As Long = &H3F
    Private Const KEY_QUERY_VALUE As Long = &H1
    Private Const KEY_ENUMERATE_SUB_KEYS As Long = &H8
    Private Const KEY_NOTIFY As Long = &H10
    Private Const KEY_READ = ((READ_CONTROL Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))

  11. #11
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    Well, these aren't calls, but constants. Because they are defined as private, they should go in the general declaration section (just under Option Explicit would be fine) of the module that uses them.

  12. #12
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    sussed

    Sussed it but thanks.

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