Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Detecting when the week number changes

Posted on 2003-10-28
2
Medium Priority
?
162 Views
Last Modified: 2010-05-03
Hi Experts,

I know how to get the week number in visual basic using:

datepart("ww", date)

But does anyone know how to trigger an event when the week number changes?

Preferably without the use of a timer control


Thanks,
Robbrownuk
0
Comment
Question by:robbrownuk
2 Comments
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 9633016
You do need to create a 'timer' to listening your request, then your application then can rect based on the response returned from the listener.

Alternatively by Not using a timer control, you can do a timer via SetTimer API, example like below:

http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q180/7/36.asp&NoWebContent=1

http://www.mvps.org/vbnet/code/forms/flashwindowsettimer.htm

Hope this helps
0
 
LVL 16

Accepted Solution

by:
JohnBPrice earned 90 total points
ID: 9633874
Are you just waiting for the week to change?  A simple way would be to sleep until it happens.  Note you don't want to sleep too long at a shot or your app won't respond to shutdown requests, etc.

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub Command1_Click()
    Dim currentweek As Integer
    currentweek = DatePart("ww", Date)
    While currentweek = DatePart("ww", Date)
        Sleep (5000) 'sleep for 5 seconds
    Wend
    'now the week has changed
End Sub
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Suggested Courses

885 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