السلام عليكم اخواني الاعزاء
كيف يمكن استرجاع جميع تواريخ يوم معين خلال شهر
بمعنى اريد ادخال يوم السبت لشهر اغسطس واحصل على تاريخ كل يوم سبت في نفس الشهر
تفضل اخي هذة هي المثود تقوم بالمطلوب
كود :
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
وهذا مثال لتوضيح الطريقة :