28-08-19, 05:47 PM
تفضل اخي هذة هي المثود تقوم بالمطلوب
كود :
Public Function dowInMonth(whDayOfWeek As DayOfWeek, Optional theDate As DateTime = Nothing) As List(Of DateTime)
'returns all days of week for a given month
If theDate = Nothing Then theDate = DateTime.Now
Dim d As DateTime = New DateTime(theDate.Year, theDate.Month, 1) 'first day of month
'calculate the first day of week
d = d.AddDays(whDayOfWeek - d.DayOfWeek)
If d.Month <> theDate.Month Then
d = d.AddDays(7)
End If
'return all of the days of week
dowInMonth = New List(Of Date)
Do While d.Month = theDate.Month
dowInMonth.Add(d)
d = d.AddDays(7)
Loop
End Functionوهذا مثال لتوضيح الطريقة :
