Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

testing time intervals on the timer control 1

Status
Not open for further replies.

psybertek

Technical User
Mar 26, 2002
30
US
Hello all, It's me again.

OK, the base of this question is, I am trying to test if a specific amount of time has elapsed, (IE) 1 hour 30 min. ( I am trying to cut down the amount of cigarrettes I smoke a day, so I get one every hour and a half) anyway, I know what I want it to do, my problem is formatting 'myinterval' for 90 minutes so that my if ... then segment can test to see if myinterval has elapsed.
_______________________________________________________
Option Explicit
Dim myinterval

Private Sub Form_Load()
myinterval = ?
starttime = Time
Label2.Caption = starttime
DirectSS1.Speak (starttime)
if time >= starttime + myinterval then
directss1.speak (time)
end if
End Sub

Private Sub Timer1_Timer()
Label1.Caption = Time
End Sub
__________________________________________

any help would be greatly appreciated.

>:):O> Psybertek >:):O>
____________________________
"Computer junkies never die, They just upload."
 
If this is going to be a program that will be doing other things, then you might try something like the following, with Timer1 being set to an interval of 60000 (1 Minute)

Dim NextInterval as Date

Private Sub Form_Load()

Label1.Caption = 90
NextInterval = DateAdd("n", 90, Now()) ' Time 90 Mins from Now

End Sub

Private Sub Timer1_Timer()

Dim ThisTime As Integer

' How many minutes between Now and the Next Break
ThisTime = DateDiff("n", Now(), NextInterval)
If (ThisTime < 0) Then
MsgBox &quot;Proceed with One&quot;
Label1.Caption = 90
NextInterval = DateAdd(&quot;n&quot;, 90, Now()) ' Set New Next
Else
Label1.Caption = ThisTime
DoEvents
End If

End Sub
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top