Solved

make a vb6 program do something every 15 minutes all day

Posted on 2013-11-02
11
403 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
Comment Utility
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
Comment Utility
Thanks  GrahamSkan, but that seems to only work one time: On form load
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
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
 
LVL 76

Expert Comment

by:GrahamSkan
Comment Utility
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
Comment Utility
Thanks DaveBaldwin, but that would take to writing to Scheduled Tasks, which i know nothing about
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
thanks that works
0
 
LVL 76

Expert Comment

by:GrahamSkan
Comment Utility
Thanks.

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

Expert Comment

by:Dave Baldwin
Comment Utility
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
Comment Utility
Thanks DaveBaldwin
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now