-
Anyone???
I use this to change an image on the 1/4 hour
Dim curTime As Date
curTime = Format(Now, "hh:mm:ss AMPM")
'change picture every 1/4 hour
If curTime = "08:00:00 AM" Then Call cmdRandom_Click
If curTime = "08:15:00 AM" Then Call cmdRandom_Click
If curTime = "08:30:00 AM" Then Call cmdRandom_Click
If curTime = "08:45:00 AM" Then Call cmdRandom_Click
I would like the user to be able to choose between
10 seconds, 20seconds, 40seconds, 10 min, 20, min, 40 min
one problem....
I haven't a clue how to go about this or even if it can be done.
-
use the gettickcount API
put this in a module
Code:
Public Declare Function GetTickCount Lib "kernel32" () As Long
put this in a command button, or whatever to fire it up
Code:
Private Sub Command1_Click()
Dim Count As Long
Dim Interval As Long
Dim EndTime As Long
Dim Temp As Long
Dim NextTick As Long
EndTime = (60 * 15) ' 15 minutes
Interval = 1000
While Count < EndTime
Temp = GetTickCount
If NextTick < Temp Then 'Next tick reached
NextTick = Temp + Interval 'Set next tick time
Count = Count + 1 'Increase count
End If
DoEvents 'Handle windows messages (like KeyDown, MouseDown,...)
Wend
Call cmdRandom_Click
End Sub
lets say you wanted to run it 4 times.
then add a loop
like
Code:
Do Until NewVar = 4
'the code I gave you here
Loop
to change the time, all you have to do is
change the "EndTime" Variable.
Thanks to Fox, I downloaded his gettickcount demo, and I took alot of this code from him ;)
-
thanks
Ok, I'll give it a go...
thanks,
-
I forgot to add, you will have to increment the new variable if you want to loop
Code:
'add this to the loop
NewVar = NewVar + 1
-
question
why would I want to loop it.
Not sure what is happening
currently I use a timer and it checks for me
If I run it once without a loop what exactly does it do.
Seems to me it counts the tickers until 15 min is reached and then it calls random click...so if I want it to check all day long I would have to loop it for 96 times...one for each 1/4 hour of the day.
Is this how it works...
one other thing is I am changing between 2 forms..
ie..I form for add, delete, manipulate, etc and the other
for just displaying images. So I am assuming if I put the code into the load or active it is restarted each time a form is called and that would throw off the change time.
[Edited by HeSaidJoe on 06-18-2000 at 11:00 PM]