ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

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

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

The DaysInMonth() method is used to get the number of the day in the specified month of the specified year.

Syntax:

Function DaysInMonth (ByVal year as Integer, ByVal month as Integer) as Integer

Parameters:

  • Year : Specified Year
  • Date2 : Specified month

Return Value: It returns the number of the day in the specified month of the specified year.

Program/Source Code:

The source code to demonstrate the DaysInMonth() method of the DateTime class is given below. The given program is compiled and executed successfully.

'VB.NET program to demonstrate DaysInMonth() method of 
'DateTime class.

Imports System

Module Module1
    Sub Main()
        Dim days As Integer = 0

        days = DateTime.DaysInMonth(2021, 2)

        Console.WriteLine("Number of Days in Feb 2021 are: {0}", days)
    End Sub
End Module

Output:

Number of Days in Feb 2021 are: 28
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 an integer variable days initialized with 0, Here, we got the number of days in February month of the year 2021 that is 28. After that, we print the number of days on the console screen.

VB.Net Date & Time Programs »

ADVERTISEMENT
ADVERTISEMENT




Comments and Discussions

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.