Home »
        VB.Net »
        VB.Net Programs
    
    VB.Net program to demonstrate the IsLeapYear() method of DateTime class
    
    
    
    
	    
		    By Nidhi Last Updated : November 11, 2024
	    
    
    
    DateTime.IsLeapYear() Method in VB.Net
    The IsLeapYear() method is used to check the specified year is a leap year or not.
    
    Syntax
Function IsLeapYear(ByVal year as Integer) as Boolean
    Parameter(s)
    
    Return Value
    It returns True if the specified year is leap year otherwise it returns False value.
    VB.Net code to demonstrate the example of DateTime.IsLeapYear() method
    The source code to demonstrate the IsLeapYear() method of the DateTime class is given below. The given program is compiled and executed successfully.
'VB.NET program to demonstrate IsLeapYear() method of 
'DateTime class.
Imports System
Module Module1
    Sub Main()
        Dim ret As Boolean = False
        ret = DateTime.IsLeapYear(2024)
        If (ret = True) Then
            Console.WriteLine("Specified year is leap year")
        Else
            Console.WriteLine("Specified year is not leap year")
        End If
    End Sub
End Module
Output
Specified year is leap year
Press any key to continue . . .
    Explanation
    In the above program, we created a module Module1 that contains the Main() function. The Main() function is the entry point for the program.
    In the Main() function, we created a boolean variable ret that is initialized with False. Here, we checked specified year is a leap year or not using IsLeapYear() method of DateTime class and print the appropriate message on the console screen.
    
    VB.Net Date & Time Programs »
    
    
    
    
   
    
  
    Advertisement
    
    
    
  
  
    Advertisement