Number of days in a month

Dim daysInMonth As Integer = Date.DaysInMonth(Now.Year, Now.Month)

MsgBox(String.Format("Number of days in the current month: {0}", daysInMonth))

Is this a leap year

Dim leapYear As Boolean = Date.IsLeapYear(Now.Year)

MsgBox(String.Format("{0} is a leap year: {1}", Now.Year, leapYear))

Current date and time

Dim rightNow As Date = Now Dim result As New  System.Text.StringBuilder

result.Append("Date: ").AppendLine(rightNow.ToShortDateString) result.Append("Time: ").AppendLine(rightNow.ToShortTimeString) MsgBox(result.ToString())

Get the exact date and time

this will display the exact date and time when the program is run

Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MsgBox(Date.Now)
End Sub
End Class