How to calculate the future occurrences of Friday the 13th in VB.NET

1 Answer

0 votes
Imports System

Class FridayThe13ths
    Private Shared Sub FindFridayThe13ths(ByVal startYear As Integer, ByVal endYear As Integer)
        For year As Integer = startYear To endYear

            For month As Integer = 1 To 12
				Dim dt As DateTime = New DateTime(year, month, 13)

				If dt.DayOfWeek = DayOfWeek.Friday Then
                    Console.WriteLine($"Friday the 13th: {year}-{month}-13")
                End If
            Next
        Next
    End Sub

    Public Shared Sub Main()
        FindFridayThe13ths(2025, 2031)
    End Sub
End Class


 
' run
'
' Friday the 13th: 2025-6-13
' Friday the 13th: 2026-2-13
' Friday the 13th: 2026-3-13
' Friday the 13th: 2026-11-13
' Friday the 13th: 2027-8-13
' Friday the 13th: 2028-10-13
' Friday the 13th: 2029-4-13
' Friday the 13th: 2029-7-13
' Friday the 13th: 2030-9-13
' Friday the 13th: 2030-12-13
' Friday the 13th: 2031-6-13
'

 



answered May 31, 2025 by avibootz
...