Solved

make a vb6 program do something every 15 minutes all day

Posted on 2013-11-02
11
406 Views
Last Modified: 2013-11-02
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
Comment
Question by:isnoend2001
  • 5
  • 4
  • 2
11 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 39619079
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
 

Author Comment

by:isnoend2001
ID: 39619103
Thanks  GrahamSkan, but that seems to only work one time: On form load
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39619119
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 76

Expert Comment

by:GrahamSkan
ID: 39619123
DaveBaldwin's suggestion is another good way of doing the job. However I will try to debug my own VB solution.
0
 

Author Comment

by:isnoend2001
ID: 39619133
Thanks DaveBaldwin, but that would take to writing to Scheduled Tasks, which i know nothing about
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 39619139
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 39619143
You don't need code to schedule tasks, but I'll leave DB to explain how easy it is.
0
 

Author Closing Comment

by:isnoend2001
ID: 39619150
thanks that works
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 39619155
Thanks.

I should remember that "m" doesn't always mean "month" in the general consideration of timecode interpretation.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39619188
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
 

Author Comment

by:isnoend2001
ID: 39619236
Thanks DaveBaldwin
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question