[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 416
  • Last Modified:

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?
0
isnoend2001
Asked:
isnoend2001
  • 5
  • 4
  • 2
1 Solution
 
GrahamSkanCommented:
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
 
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
GrahamSkanCommented:
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
 
GrahamSkanCommented:
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
 
GrahamSkanCommented:
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
 
GrahamSkanCommented:
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now