Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Execute code on specific day

Posted on 2013-06-18
4
Medium Priority
?
261 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
[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
  • 2
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
Faustulus earned 2000 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

Independent Software Vendors: 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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Suggested Courses

721 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