This Program Calculate Your age According to your birth day. There are various methods for this but I think this is the easiest way for this.
C#.net code for Age Calculator
Download Sample Code
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Age_calculater { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void processbutton_Click(object sender, EventArgs e) { DateTime dateOfbirth; DateTime today; string name = ""; int year, month, day; name = nameTextBox.Text; year=int.Parse(yearTextBox.Text); month = int.Parse(monthTextBox.Text); day = int.Parse(dayTextBox.Text); dateOfbirth = new DateTime(year, month, day); today = DateTime.Today; TimeSpan differance = today.Subtract(dateOfbirth); DateTime age = DateTime.MinValue + differance;//min 01/01/01 year = age.Year-1; month = age.Month - 1; day = age.Day - 1; string result = "Dear, " + name + "\nYour Age is " + "\n" + year + " years\n" + month + " Months\n" + day + " Days"; resultlable.Text = result; } } }
This comment has been removed by the author.
ReplyDelete