' sundays.vb Imports System Imports System.Collections.Generic Class GetSundays Shared Sub main() Dim days As DateTime() = GetSundays(2008, 9) For Each d As DateTime In days Console.WriteLine(d) Next ' 出力: ' 2008/09/07 0:00:00 ' 2008/09/14 0:00:00 ' 2008/09/21 0:00:00 ' 2008/09/28 0:00:00 End Sub Shared Function GetSundays(ByVal y As Integer, ByVal m As Integer) As DateTime() Dim days As New List(Of DateTime)() Dim d As DateTime = New DateTime(y, m, 1) While d.Month = m If d.DayOfWeek = DayOfWeek.Sunday Then days.Add(d) End If d = d.AddDays(1) End While Return days.ToArray() End Function End Class ' コンパイル方法:sundays.vb