View Single Post
  #1 (permalink)  
Old August 28th, 2012, 12:17 PM
Majenko Majenko is offline
Registered User
 
Join Date: Aug 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with end of month

Hi,
When the user chooses the end of month as date from DateTimePicker,
The months should be incremented correctely.

For example, if one has date 31/12/2012, he should receive:
31/01/2012, 29/02/2012, 31/03/2012, and so on.

But with the code below, the date doesn’t move from the day 29:
31/01/2012, 29/02/2012/, 29/03/2012, 29/04/2012,...

Any help would be appreciated with great many thanks.

This is the code:

Dim dtN As Date = DateTimePicker.Value.ToShortDateString
Dim i as integer
For i = 1 To Periods
dtN = dtN.AddMonths(1)
dgvAmortis.Rows.Add()
dgvAmortis.Item("datecol", i - 1).Value = Format(dtN, "dd/MM/yyyy").ToString