Click here to Skip to main content
15,891,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have three textboxes. In TB1 I enter 'startdate'. In Tb2 I enter 20 days. In TB3 I want the result 'enddate'. I used 1 datetime variables named as 'v_startdate',variable 'v_adddays' for 20 days from TB2 and a string variable 'v_expdt' and tried with the following code. It is not working .Can anyone guide?

string v_expdt = v_adddays + v_startdt;
Posted
Comments
[no name] 7-May-13 8:11am    
What is wrong with using the DateTime.AddDays method?

1) I would not use Textboxes instead use DateTimePickers for the date information.
2) Use a NumberUpDown for the number of days to increment by.

So you have 3 controls

C#
DateTimePicker StartDate
DateTimePicker EndDate
NumberUpDown   NoOfDays

EndDate.Value = StartDate.Value.AddDays(NoOfDays.Value);


Something like that should do the job.

You could put some handling in the ValueChanged event of the numberupdown control so that when the value is altered EndDate is automatically updated.
 
Share this answer
 
C#
v_expdt = v_startdt.AddDays(v_adddays).ToString();
 
Share this answer
 
v2

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