Solved

make a vb6 program do something every 15 minutes all day

Posted on 2013-11-02
11
408 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Acccess - Update Field in Table when report is printed 6 51
VB6 Compile Compatibility Issue 4 122
Advice in Xamarin 21 109
pop out of webbrowser1 control vba6 5 44
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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

726 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