Solved

Detecting when the week number changes

Posted on 2003-10-28
2
157 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 50

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA color chart bars 12 84
Recommendation vb6 to vb.net or others 14 141
Passing a Text Box name to a Sub 6 96
Added a column screws up code 5 57
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…
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…
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 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…

816 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

9 Experts available now in Live!

Get 1:1 Help Now