Perpetual Calendar
By: Lorenzo Dalla Vecchia Date: 21/10/2001
File:

perpcal.zip

Size:

826 bytes

Download now!

This module contains an interesting procedure that, given a valid date in any format, returns the corrensponding day of week.

Note that the same thing is accomplished by the pre-made function Weekday, included in VB.

Syntax

WDay(FullDate)

Parameters

FullDate: a valid date in any format (can be Date or String).

Type of data

FullDate: Date

Returns

An Integer value identifying the day: 0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday.
If the source date is invalid, -1 is returned.

-

Example:
Ask for a date and print day of week.

Dim D As String
'Ask for date
Do
    D = InputBox("Enter a valid date")
Loop While D = ""
'Return result
Select Case WDay(D)
    Case 0: MsgBox "Sunday"
   
Case 1: MsgBox "Monday"
   
Case 2: MsgBox "Tuesday"
   
Case 3: MsgBox "Wednesday"
   
Case 4: MsgBox "Thursday"
   
Case 5: MsgBox "Friday"
   
Case 6: MsgBox "Saturday"
   
Case -1: MsgBox "Invalid date!"
End Select

The function is contained in a module. You can include it in any program of yours.

Click Here!


Visual Basic Programming Zone is a website by Lorenzo Dalla Vecchia.
To contact the Webmaster, click here.
Hosted by InWind: www.inwind.it