ADVERTISEMENT
ADVERTISEMENT

VB.Net program to demonstrate the IsLeapYear() method of DateTime class

Here, we are going to demonstrate the IsLeapYear() method of DateTime class in VB.Net.
Submitted by Nidhi, on January 21, 2021

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

Parameters:

  • year : Specified year.

Return Value: It returns True if the specified year is leap year otherwise it returns False value.

Program/Source Code:

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



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.