Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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 27-Jan-13 20:03pm
Edited 27-Jan-13 20:04pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Dim c As New DateTime(2013, 1, 28)
 
c = c.AddYears(3)
 
  Permalink  
Comments
suhan 2012 at 28-Jan-13 3:31am
   
It works now. Thanks.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

What about: DateAndTime.DateAdd[^] with DateInterval.Year?
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
 
for increment date by 3 years
you can write the syntax like this...
 
currentDate=currentDate.AddYears(3);
 
for more information you can check with this links
http://msdn.microsoft.com/en-us/library/system.datetime.addyears.aspx[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Dim textBox1Date as DateTime;
 
textBox1Date=DateTime.Parse(TextBox1.Text);
 
Dim newDate as DateTime;
 
newDate = textBox1Date.AddYears(3);
 
TextBox2.Text=String.parse(newDate);
  Permalink  
Comments
suhan 2012 at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 453
1 CPallini 333
2 George Jonsson 270
3 OriginalGriff 159
4 Prasad Khandekar 135
0 OriginalGriff 4,613
1 CPallini 3,340
2 Sergey Alexandrovich Kryukov 2,879
3 George Jonsson 2,264
4 Gihan Liyanage 2,020


Advertise | Privacy | Mobile
Web03 | 2.8.140905.1 | Last Updated 28 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100