setting date 2 to be 365 days later than date1

  • Thread starter Thread starter Scott
  • Start date Start date
S

Scott

Hi

I have done a program that is to work out travel insurance for single and
annual trips. For single trips I put in a start and end date no problems.
But for an annual trip I only need to insert the start date of the cover and
I want the program to automatically work out when the last day of the cover
is and make that non editable. I have an idea how to do this, but how do I
go about coding this part to do this automatically???

Regards

Scott
 
You can use something like this:

Dim Date1 As DateTime = DateTime.Now
Dim Date2 As DateTime = Date1.AddDays(365)
 
Scott,
As Chris suggests you can use DateTime.AddDays to add a number of days to a
date.

There is also DateTime.AddYears and DateTime.AddMonths that you may find
useful.

Dim Date1 As DateTime = DateTime.Now
Dim Date2 As DateTime = Date1.AddYears(1)
Dim Date3 As DateTime = Date1.AddMonths(12)

For the complete list of methods that DateTime objects (values) support see:

http://msdn.microsoft.com/library/d...pref/html/frlrfsystemdatetimememberstopic.asp

On a form if I did not want the user to change the second Date value, I
would make the control read only (see the Enabled property).

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top