I have created a windows form application in c# in which input from user is taken .I want to calculate time spent by user in between two submissions.How can I do that?
You can use two global DateTime variable and in click twice button diff to variable;
private DateTime btn1Click ;
private DateTime btn2click;
private void btn1_Click(object sender, EventArgs e)
{
btn1Click = DateTime.Now;
}
private void btn2_Click(object sender, EventArgs e)
{
btn2click = DateTime.Now;
}
and use this code for diff time:
TimeSpan timespan = btn2click - btn1Click;
In same button :
private DateTime btnClick1 ;
private DateTime btnClick2;
private void btn_Click(object sender, EventArgs e)
{
if (btnClick1==null)
{
btnClick1 = DateTime.Now;
}
else
{
btnClick2 = DateTime.Now;
}
}