Solved

Add Date

Posted on 2008-06-25
4
720 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…

710 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