Solved

Add Date

Posted on 2008-06-25
4
712 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:Chrispy2811
  • 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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 video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now