Share leap year program in vb.net,

haiha730

New member
#vb.net #Leap Năm chương trình năm

Một năm bước nhảy là một năm có 366 ngày thay vì 365 ngày thông thường.Điều này xảy ra cứ sau bốn năm, ngoại trừ nhiều năm chia hết 100 nhưng không phải là 400. Ví dụ, năm 2020 là một năm bước nhảy, nhưng năm 2019 và 2021 thì không.

Chương trình sau đây trong VB.NET sẽ xác định xem một năm nhất định có phải là một năm bước nhảy hay không.

`` `VBNet
Chức năng isLeapyear (năm như số nguyên) như boolean
Nếu năm mod 4 = 0 thì
Nếu năm mod 100 = 0 thì
Nếu năm mod 400 = 0 thì
IsLeapyear = true
Khác
IsLeapyear = false
Kết thúc nếu
Khác
IsLeapyear = true
Kết thúc nếu
Khác
IsLeapyear = false
Kết thúc nếu
Hàm cuối
`` `

Để sử dụng chức năng này, chỉ cần gọi nó với năm bạn muốn kiểm tra như một đối số.Ví dụ: mã sau sẽ in `true` nếu năm là năm 2020 và 'false' nếu năm là năm 2019.

`` `VBNet
Năm mờ như số nguyên = 2020
Nếu isLeapyear (năm) thì
Console.WriteLine ("Năm {0} là một năm bước nhảy.", Năm)
Khác
Console.WriteLine ("Năm {0} không phải là một năm nhảy.", Năm)
Kết thúc nếu
`` `

## hashtags

* #Leap năm
* Chương trình năm #Leap
* #Programming
* #Ngày và giờ
=======================================
#vb.net #Leap year #Leap year program #Programming #Date and time ## Leap Year Program in VB.NET

A leap year is a year that has 366 days instead of the usual 365 days. This occurs every four years, except for years that are divisible by 100 but not by 400. For example, 2020 was a leap year, but 2019 and 2021 were not.

The following program in VB.NET will determine whether a given year is a leap year.

```vbnet
Function IsLeapYear(year As Integer) As Boolean
If year Mod 4 = 0 Then
If year Mod 100 = 0 Then
If year Mod 400 = 0 Then
IsLeapYear = True
Else
IsLeapYear = False
End If
Else
IsLeapYear = True
End If
Else
IsLeapYear = False
End If
End Function
```

To use this function, simply call it with the year you want to check as an argument. For example, the following code will print `True` if the year is 2020, and `False` if the year is 2019.

```vbnet
Dim year As Integer = 2020
If IsLeapYear(year) Then
Console.WriteLine("The year {0} is a leap year.", year)
Else
Console.WriteLine("The year {0} is not a leap year.", year)
End If
```

## Hashtags

* #Leap year
* #Leap year program
* #Programming
* #Date and time
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top