Check for LEAP YEAR in VB.Net
January 5th, 2009Nothing overly impressive here but wanted to point out the built-in functionality of VB.Net to let you know if your year is a leap year or not.
HERE IS THE CULPRIT:
If Date.IsLeapYear(Int(TextBox1.Text)) Then
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs)Handles Button1.Click
If Not TextBox1.Text = "" Then
If IsNumeric(TextBox1.Text) Then
If Int(TextBox1.Text) > 1950 And
Int(TextBox1.Text) < 2500 Then
If Date.IsLeapYear(Int(TextBox1.Text)) Then
TextBox2.Text = "This IS a LEAP YEAR!"
Else
TextBox2.Text = "Not a leap year."
End If
Else
TextBox2.Text = "SOMETHING between 1950 & 2500 please."
End If
Else
TextBox2.Text = "NOT NUMERIC"
End If
Else
TextBox2.Text = "BLANK... enter something."
End If
End Sub
End Class
