Salut
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Private Function GetListdate(ByVal month As Integer, ByVal dayweek As Integer) As List(Of DateTime)
Dim first, nextdate As DateTime
Dim listdates As New List(Of DateTime)
Dim d As Integer
Dim us As New CultureInfo("en-US")
first = Convert.ToDateTime("01/" & month.ToString)
d = us.DateTimeFormat.Calendar.GetDayOfWeek(first)
If dayweek - d < 0 Then
nextdate = first.AddDays(7 - (d - dayweek))
Else
nextdate = first.AddDays(dayweek - d)
End If
While nextdate.Month = month
listdates.Add(nextdate)
nextdate = nextdate.AddDays(7)
End While
Return listdates
End Function |
pour utiliser
tous les mercredi de novembre
1 2
| Dim listdates As New List(Of DateTime)
listdates = GetListdate(11, 2) |
tous les dimanches
listdates = GetListdate(11, 0)
Partager