Solved

Detecting when the week number changes

Posted on 2003-10-28
2
155 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 49

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 30 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

762 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

19 Experts available now in Live!

Get 1:1 Help Now