swilli6926
asked on
Date Question
If I had a simple form with one textbox and a listbox and I wanted to type the year into the textbox (ex. 2004 or 2005 etc) and have the listbox populate with
all the dates "??/??/????" that start each week. Like all the Sundays. How would that be done?
Any Suggestions?
all the dates "??/??/????" that start each week. Like all the Sundays. How would that be done?
Any Suggestions?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ok... Idle's is a lot neater than mine (and takes into account different days :P)
Sub ListAllSundays(ByVal YearNum As Integer, Byval ListX as Listbox)
Dim i As Integer
Dim thisDate As Date
Dim firstSunday As Integer
For i = 1 To 7
thisDate = New Date(YearNum , 1, i)
If thisDate.DayOfWeek = DayOfWeek.Sunday Then
Exit For
End If
Next
Do While thisDate.Year = YearNum
ListX.Items.Add(thisDate.T
thisDate = thisDate.AddDays(7)
Loop
End Sub