|
-
Nov 9th, 2000, 04:25 PM
#1
Thread Starter
PowerPoster
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
-
Nov 9th, 2000, 04:34 PM
#2
mm = month
nn = minutes
format(lRtrn, "hh:nn:ss")
-
Nov 17th, 2000, 04:24 PM
#3
Thread Starter
PowerPoster
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.
-
Nov 17th, 2000, 04:37 PM
#4
Addicted Member
To get minutes you devide it by 60000 (1000 = 1sec). You can then devide that further to get min & sec or somthing.
-
Nov 17th, 2000, 05:26 PM
#5
_______
<?>
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
-
Nov 17th, 2000, 05:56 PM
#6
Thread Starter
PowerPoster
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.)
-
Nov 22nd, 2000, 08:09 AM
#7
Hyperactive Member
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.?
-
Nov 22nd, 2000, 10:39 AM
#8
Thread Starter
PowerPoster
You can't get the date in seconds because it counts the amout of time that the computer has been running.
-
Nov 22nd, 2000, 10:50 AM
#9
transcendental analytic
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.
-
Nov 22nd, 2000, 11:35 AM
#10
Hyperactive Member
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))
-
Nov 22nd, 2000, 12:43 PM
#11
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.
-
Nov 23rd, 2000, 05:05 AM
#12
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|