MIT Guru-lk

MIT Guru-lk

Thursday, May 24, 2012

Age Calculater With C# 2010

Posted by Mit Guru  |  at  1:48 AM 1 comment


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;

}

}

}

About the Author

Write admin description here..

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

Related posts

1 comment:

© 2013 MIT Tutorials. WP Theme-junkie converted by BloggerTheme9
back to top