This is a simple age calculator.
You just have to provide your Date Of Birth and a date to which you want your age…….
Press Calculate Button And it will calculate your age …
We need two DatePicker Control.
1 Button and 3 label control.
So here is the code begin
Public Class Form1
Dim dt1 As Date
Dim dt2 As Date
Dim dt3 As TimeSpan
Dim diff As Double
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
dt1 = Me.DateTimePicker1.Value.ToShortDateString
dt2 = Me.DateTimePicker2.Value.ToShortDateString
dt3 = (dt2 - dt1)
diff = dt3.Days
Me.Label1.Text = ("Your Age is " + Str(Int(diff / 365)) + " Year ")
diff = diff Mod 365
Me.Label1.Text = Me.Label1.Text + (Str(Int(diff / 30)) + " Month(s)")
diff = diff Mod 30
Me.Label1.Text = Me.Label1.Text + (Str(diff) + " Day(s)")
End Sub
End Class
Need illustration ? Just leave a reply or comment……