How to make loop month by month ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everybody !

i'm begining with Visual Basic Express Edition and i try
to make a loop month by month between two dates.

I have insuccessfully tried something like this :

From DateOfDateTimePicker1 to DateOfDateTimePicker2
Msgbox (Month & vbcrlf & Year)
Next

Thank you for your attention,

Estelle (from Paris)
 
Estelle,

There are a lot of approaches for that. Let a service run all the time on
your computer.

However that has no sense than your computer should never be shut down.

You can set the date in your register and start your program up as a service
and let it look every 10 minutes to that register. And than using resources.

The most advised option is just to use the standard Windows Scheduler.

Cor
 
If I understand your question correctly, you might try code such as:

'get months from dateTime1 to dateTime2
Dim lesser, greater As DateTime
If dateTime1 < dateTime2 Then
lesser = dateTime1
greater = dateTime2
Else
lesser = dateTime2
greater = dateTime1
End If

While lesser <= greater
Console.WriteLine(lesser.Month)
lesser = lesser.AddMonths(1)
End While

===============
Clay Burch
Syncfusion, Inc.
 
Hi Clay

it's wonderful ! you have exactly understood what I needed

Thank you very much !

Evelyne
 
Back
Top