make a vb6 program do something every 15 minutes all day

I am trying to make a vb6 prgram check the status of my website every 15 minutes all day long
How can this be done?
isnoend2001Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
GrahamSkanConnect With a Mentor RetiredCommented:
Well it worked with the revised (test-only) interval value set to 2
Option Explicit
Dim NextTime As Date
Const intervalminutes = 2
Private Sub Form_Load()
    DoAction
    NextTime = DateAdd("n", intervalminutes, Now)
    Timer1.Interval = 60000 'one minute
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
    If Now >= NextTime Then
        DoAction
        NextTime = DateAdd("n", intervalminutes, Now)
    End If
End Sub
Sub DoAction()
MsgBox "executing action now"
'CheckWebsite
'...
End Sub

Open in new window

0
 
GrahamSkanRetiredCommented:
I would use a Timer control on a form.
Option Explicit
Dim NextTime As Date 
Private Sub Form_Load()
    DoAction
    NextTime = DateAdd("n", 15, Now)
    Timer1.Interval = 60000 'one minute
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
    If Now >= NextTime Then
        DoAction
        NextTime = DateAdd("n", 15, Now)
    End If
End Sub

Sub DoAction()
'CheckWebsite
'...
End Sub

Open in new window


Note. Post submission edit.  Corrected time unit from "m" (month) to "n" ( minute)
0
 
isnoend2001Author Commented:
Thanks  GrahamSkan, but that seems to only work one time: On form load
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Dave BaldwinFixer of ProblemsCommented:
Why don't you write a simple program that checks it once and put it in Scheduled Tasks to run every 15 minutes?  That way, you don't have to write the timing part.
0
 
GrahamSkanRetiredCommented:
DaveBaldwin's suggestion is another good way of doing the job. However I will try to debug my own VB solution.
0
 
isnoend2001Author Commented:
Thanks DaveBaldwin, but that would take to writing to Scheduled Tasks, which i know nothing about
0
 
GrahamSkanRetiredCommented:
You don't need code to schedule tasks, but I'll leave DB to explain how easy it is.
0
 
isnoend2001Author Commented:
thanks that works
0
 
GrahamSkanRetiredCommented:
Thanks.

I should remember that "m" doesn't always mean "month" in the general consideration of timecode interpretation.
0
 
Dave BaldwinFixer of ProblemsCommented:
Scheduled Tasks is in the Windows Control Panel.  Open it up and click on Add Task.  A 'wizard' dialog opens up and you follow the instructions.  On Windows XP, the smallest time interval is an hour though.
0
 
isnoend2001Author Commented:
Thanks DaveBaldwin
0
All Courses

From novice to tech pro — start learning today.