Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 2 text boxes on the form. First one is to enter a date, for example 28/1/2013. and the second one will get the result by increasing the date value of first text box by 3 years.
Can I achieve this task? if so, please tell me how? I know the code for this task should be written in textchanged event. But don't know what should I write.
Posted
Updated 27-Jan-13 20:04pm
v2

VB
Dim c As New DateTime(2013, 1, 28)

c = c.AddYears(3)
 
Share this answer
 
Comments
suhan 2012 28-Jan-13 3:31am    
It works now. Thanks.
What about: DateAndTime.DateAdd[^] with DateInterval.Year?
 
Share this answer
 
Hi,

for increment date by 3 years
you can write the syntax like this...

C#
currentDate=currentDate.AddYears(3);


for more information you can check with this links
http://msdn.microsoft.com/en-us/library/system.datetime.addyears.aspx[^]
 
Share this answer
 
Dim textBox1Date as DateTime;

textBox1Date=DateTime.Parse(TextBox1.Text);

Dim newDate as DateTime;

newDate = textBox1Date.AddYears(3);

TextBox2.Text=String.parse(newDate);
 
Share this answer
 
Comments
suhan 2012 28-Jan-13 3:31am    
Thanks.

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