Solved

Add Date

Posted on 2008-06-25
4
716 Views
Last Modified: 2013-11-05
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

0
Comment
Question by:Chris Pfeiffer
  • 2
4 Comments
 
LVL 48

Expert Comment

by:jpaulino
ID: 21868283
You can do:

txtE3.Text = _date.AddMonths(16)
0
 
LVL 27

Accepted Solution

by:
planocz earned 500 total points
ID: 21868406
try this...
  Dim _Date As Date = dtpstart.Value.Date
        Me.textbox2.Text = _date.AddMonths(6)
        textbox3.Text = CType(TextBox2.Text, Date).AddMonths(10)
0
 
LVL 27

Expert Comment

by:planocz
ID: 21868718
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
0
 
LVL 14

Expert Comment

by:raja_ind82
ID: 21869102
Try this..
TextBox1.Text = DateAdd(DateInterval.Month, 10, Now)

Regards,
M.Raja
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question