Solved

Execute code on specific day

Posted on 2013-06-18
4
248 Views
Last Modified: 2013-06-19
The code below executes the 9th of each month.  I would like to change the following vb6 code to execute when it is only July 9,2013.

currentservertime already contains the current date.  

How do I do that?

If Day(currentServerTime) < 9 Then
                    'Add code here
            End If

Open in new window

0
Comment
Question by:al4629740
  • 2
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
Faustulus earned 500 total points
ID: 39258237
How about this?
If Date = DateSerial(2013,7,9) Then
    ' add your code here
End If

Open in new window

You can expand on the idea like this:-
If Now > (DateSerial(2013,7,9) + TimeSerial(12,0,0)) Then
    ' add your code here
End If

Open in new window

This would run any time after 12 pm on July 9. Your code could include a line to abort if the time window you want to allow is exceeded.
Basically, if you wish a program to run on July 9, 2013 you would need to set a timer which would wake up the computer and run the program when the time has arrived. This is what they use for automatic backups. The above kind of code would need to be called by the user or, perhaps a startup procedure, and then refuse to run at any other time. But it could be run multiple times within the prescribed time frame unless your code includes provision to allow it to run only once.
0
 

Author Comment

by:al4629740
ID: 39258379
Can I do
July 9, 2013. 8:00pm
0
 

Author Comment

by:al4629740
ID: 39258430
This didn't work.  Do I have the format wrong

If Date = DateSerial(2013,7,9) Then
    ' add your code here
End If
0
 
LVL 14

Expert Comment

by:Faustulus
ID: 39258554
TimeSerial(20,0,0) would define 8 pm. The parameters are Hour, Minute, Second - all counting from 00:00 h military time.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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 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…
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…

759 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

21 Experts available now in Live!

Get 1:1 Help Now