What's Here?
- Members: 117,573
- Replies: 431,934
- Topics: 66,689
- Snippets: 2,395
- Tutorials: 631
- Total Online: 2,042
- Members: 58
- Guests: 1,984
Who's Online?
|
Welcome to Dream.In.Code |
|
Getting VB.NET Help is Easy!
Join 117,573 VB.NET Programmers for FREE! Ask your question and get quick answers from experts. There are 2,042 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!
|
Calculate the date of the last specified week day of the month.I.e. The last Friday.
|
Submitted By: AdamSpeight2008
|
|
|
Rating:
|
|
Views: 689 |
Language: VB.NET
|
|
Last Modified: June 30, 2008 |
Instructions: Example
Console.WriteLine(LastDayOFMonth(New Date(2008, 7, 1), DayOfWeek.Monday).ToString)
' Return 2008/7/28
|
Snippet
Private Function LastDayOFMonth(ByVal InputDate As Date,ByVal DayInWeek As DayOfWeek) As Date
Dim lastDay As New Date(InputDate.Year, InputDate.Month, 1)
While lastDay.DayOfWeek <> DayInWeek
lastDay = lastDay.AddDays(1)
End While
While lastDay.Month = InputDate.Month
lastDay = lastDay.AddDays(7)
End While
lastDay = lastDay.AddDays(-7)
Return lastDay
End Function
Copy & Paste
|
|
|
Reference Sheets
Bye Bye Ads
Free DIC T-Shirt
Related Sites
Monthly Drawing
Partners
Top Contributors
Top 10 Kudos This Month
|