Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the simple way for VB.NET to achieve a leap year

Shulou Source: shulou.com Published: 2022-06-02 11:41:00 09月28日 Update

VB.NET what is the simple way to achieve leap year, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

We must all know what a leap year is, that is, one leap in four years, no leap in a hundred years, and another leap in four hundred years. Let's take a look at how to implement this in VB.NET.

The "leap year" of the Western Gregorian calendar

A year with a leap day in the Gregorian calendar is called a leap year. On the contrary, it is a normal year, with 365 days in a normal year and 366 days in a leap year. In the Gregorian calendar (Gregorian calendar), February has 28 days in normal years and 29 days in leap years. The average month of a leap year is a leap day on February 29th.

Reasons for increasing the number of leap days

The current Gregorian calendar is calculated on the basis of the return year, which is about 365.24220 days. Because only 365 days are calculated in the Gregorian calendar in a normal year, as a result, 0.24220 × 4 = 0.9688 days will accumulate after four years, which is about one day, so an additional leap day will be added every four years to offset this 0.9688 days.

The method of calculating leap years

In the Gregorian calendar chronology, most of the years divisible by 4 are leap years, the years that are not divisible by 3200 are leap years, and those that are divisible by 400 are not leap years, for example, 1900 is a normal year, 2000 is a leap year, and 3200 years is not a leap year.

The "leap year" of the Chinese lunar calendar

In the Chinese lunar calendar, a year with leap months is called a leap year. The average year is 12 months, 354 or 355 days, and leap years are 13 months, 383 or 384 days

A simple method for calculating leap years in the Gregorian calendar in programming:

Set year year

(year is divisible by 4 and not divisible by 100) or year is divisible by 400, then that year is a leap year.

Otherwise, the year will be a normal year.

The method of judging vb.net leap years (vb.Net has added the Date.IsLeapYear method to judge, so it is not so complicated)

VB.NET basic tutorial effect picture:

The example code of the basic VB.NET tutorial is as follows:

Private Sub CheckLeapYear (ByVal Int_Year As Integer) Dim Boo_LeapYear As Boolean Boo_LeapYear = Date.IsLeapYear (Int_Year) If Boo_LeapYear Then MessageBox.Show (Int_Year & "A year is a leap year!" , "Lebo Tip") Else MessageBox.Show (Int_Year & "year is not a leap year!" , "Lebo Tip") End If End Sub

How to call the basic tutorial of VB.NET:

CheckLeapYear (Now.Year) CheckLeapYear (2000) is it helpful for you to finish reading the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Leap year Gregorian calendar ordinary year method foundation year tutorial lunar calendar return year that is China Bowang help hint complexity clarity code content reason back Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Information Xiaomi MySQL NVidia