|By: Lorenzo Dalla Vecchia Date: 21/10/2001|
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.
|FullDate: a valid date in any format (can be Date or String).|
Type of data
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.
Ask for a date and print day of week.
|Dim D As String
'Ask for date
D = InputBox("Enter a valid date")
Loop While D = ""
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!"
The function is contained in a module. You can include it in any program of yours.
|Visual Basic Programming Zone is a website by
Lorenzo Dalla Vecchia.
To contact the Webmaster, click here.
Hosted by InWind: www.inwind.it