Home >>VB.Net Programs >VB.Net program to check leap year

VB.Net program to check leap year

Write a VB.Net Program to check Leap year

Here, we will read a year from the user and then find the given year is a leap year or not and then print the required message on the console screen.

Program :

Below is the source code to check whether or not the year reached is a leap year. The program given is compiled and successfully executed.

Example


	Module Module1

    Sub Main()
        Dim year As Integer = 0
        
        Console.Write("Enter Your year : ")
        year = Integer.Parse(Console.ReadLine())

        If ((year Mod 4 = 0) AndAlso (year Mod 100 <> 0)) OrElse ((year Mod 4 = 0) AndAlso (year Mod 100 = 0) AndAlso (year Mod 400 = 0)) Then
            Console.WriteLine("Entered year is leap year")
        Else
            Console.WriteLine("Entered year is not leap year")
        End If
    End Sub
End Module
	
Output:
Enter year: 2004
Entered year is leap year

Explanation:

We created a Module1 module in the above program that contains a method Main(). We generated an integer variable year with an initial value of 0. in the Main() method.

Console.Write("Enter Your year : ")
year = Integer.Parse(Console.ReadLine())

No Sidebar ads