View Single Post
  #2 (permalink)  
Old August 12th, 2003, 02:28 PM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

You'll need to take a look at the Weekday method which you can find in the Windows Script section of the MSDN:

The Weekday method returns a 1 based number for the current day of the week, starting at 1 for a Sunday by default.

So, this should work:

Code:
If Weekday(dtNow) = Weekday(Now()) Then
  str.... etc
End If

Or, when you need multiple days, use a Select Case statement:

Select Case Weekday(dtNow)
  Case 1 ' Sunday
  ...
  Case 2 ' Monday
  etc etc
End Select
or define constants for the weekdays if you need them more often, to improve the readability of the code:

Code:
Dim vbSunday
Dim vbMonday
...
vbSunday = 1
vbMonday = 2
...
Select Case Weekday(dtNow)
  Case vbSunday
  ...
  Case vbMonday
  etc etc
End Select
Hope this helps,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote