Click here to Skip to main content
15,913,090 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
ihave taken three textbox. one is login time. another is logout time.and another is total time.if i will insert the login time and logout time ,how automaticaly it will show the total time.
Posted

Here is one possible solution:
C#
private void UpdateTotalTime()
{
  DateTime timeStart;
  DateTime timeEnd;
  if (DateTime.TryParse(textBox1.Text, out timeStart) && DateTime.TryParse(textBox2.Text, out timeEnd))
  {
    TimeSpan span = (timeEnd - timeStart);
    textBox3.Text = span.ToString("c");
  }
}

Just call this function when the text in your two input textboxes changes.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900