I have written this code to Display the time every 15 minutes using MSAgent:
(Private Sub Form_Load()
On Error Resume Next
CenterForm
LoadAgent "merlin"
theAgent.Speak "Hello"
theAgent.Hide
Gettime:
Do
Mytime = Time
Myhour = Hour(Mytime)
Myminute = Minute(Mytime)
Mysecond = Second(Mytime)
If Myminute = 15 And Mysecond = 0 Then Exit Do
If Myminute = 30 And Mysecond = 0 Then Exit Do
If Myminute = 45 And Mysecond = 0 Then Exit Do
If Myminute = 0 And Mysecond = 0 Then Exit Do
Debug.Print Myminute, Mysecond
Loop
Debug.Print "Load"
theAgent.Show
theAgent.Play "announce"
theAgent.Speak "The time is " & Myhour & ":" & Myminute & "."
theAgent.Play "announcereturn"
theAgent.Hide
Do Until Mysecond > 0
Mysecond = Second(Time)
Loop
intCnt = 15000
start = Timer
waitTime = start + intCnt
Debug.Print Timer, waitTime, "start"
Do While Timer < waitTime
Debug.Print Timer, waitTime
DoEvents
Loop
GoTo Gettime
End Sub)
The Code works. So far but it uses 50%cpu. Are there any ways of writing the timer delay routine to reduce the cpu usage. Sleep doesnt seem to be available in VB5
I'm a novice at writing code been away from coding for several years.
The OS in win XP and VB is version 5 with sp3.