Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Add Date

Posted on 2008-06-25
4
Medium Priority
?
727 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 2000 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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

722 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