Link to home
Start Free TrialLog in
Avatar of Chris Pfeiffer
Chris PfeifferFlag for Japan

asked on

Add Date

I know that this is an easy question but I just am drawing a blank right now so I have come to you...
I want to calculate many dates from a date picked from a DateTimePicker. The problem is I want it to only make the fisrt calculation off of the DTP.

See Code

Then I want another txtbox to display to show the result of 10 more months from the date in txtE3. The thing is that the value of the text box is a string and you can not use the AddMonth to it. I though that i could just keep reusing _date with the next value but I was doing something wrong. To tired right now i guess..

Thanks

Dim _Date as Date
 
_date = dtpstart.Value.Date
txtE2.Text = _date.AddMonths(6)
txtE3.Text = (the result from above then add 10 months)

Open in new window

Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

You can do:

txtE3.Text = _date.AddMonths(16)
ASKER CERTIFIED SOLUTION
Avatar of Howard Cantrell
Howard Cantrell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OR you can do this.........

Private Sub dtpstart_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dtpstart.ValueChanged
        Me.TextBox2.Text = dtpstart.Value.Date.AddMonths(6)
        Me.TextBox3.Text = CType(TextBox2.Text, Date).AddMonths(10)
    End Sub
Try this..
TextBox1.Text = DateAdd(DateInterval.Month, 10, Now)

Regards,
M.Raja