c# code for age calculate using datetimepicker and textbox in .net



This is A C# Practice 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;
        using System.Data.SqlClient;


        namespace dataentry
        {
            public partial class Age_Calculate : Form
            {
                public Age_Calculate()
                {
                    InitializeComponent();
                }
                SqlConnection asdf = new SqlConnection("Data Source=.;Initial Catalog=EManage;Integrated Security=True");
                private void label2_Click(object sender, EventArgs e)
                {

                }

           private void button9_Click_1(object sender, EventArgs e)
                {
                    DateTime from = dateTimePicker1.Value;
                    DateTime to = DateTime.Now;
                    TimeSpan TSpan = to - from;
                    double days = TSpan.TotalDays;
                    textBox1.Text = (days / 365).ToString("0");
                    MessageBox.Show((days / 365).ToString("0"));
                }
        }
        }
Video For Result:

Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Facebook Comment