...

View Full Version : Populating an array of dates with a start and an end date. VB.NET 2008



Colorfinger
08-02-2008, 01:25 AM
Hi -

I'm trying to find a good way to do this, and I'm hoping someone here might be able to point me in the right direction. I've created an array called "myDates" to hold all the dates I want my sub to operate on, but I'm having a hard time populating it. I need to cycle through all the dates between a user selected "begin" and "end" date, which are hosted in DateTimePicker2 and DateTimePicker3 respectively (and also converted out to myMonth / Day / Year and endMonth / Day / Year as integers). Here's an idea of what I've done so far (which is really just setting up a framework to determine what I will handle):



Dim myDates(101) as Date

' We need to work out how many days we are working with here.

If endYear > myYear Then

' we are spanning more than one year
If endMonth > myMonth Then
' we are spanning more than one month (ie, Jan 2008 - Feb 2009)
MsgBox("Error! Did you select more than 100 days?")

ElseIf endMonth < myMonth Then
' we are spanning more than one year, and the month is lower (ie, Dec 2008 - Jan 2009)
' MOST NORMAL SITUATION

Dim offset As New DateTimeOffset

For diq = 0 To 100
myDates(0) = DateTimePicker2.Value.Date + (SINGLE DAY CONSTANT GOES HERE MAYBE ?? )
Next

Else
' we are spanning multiple years but the month is the same (ie, Jan 2008 - Jan 2009)
MsgBox("Error! Did you select more than 100 days?")

End If
End If

So the short version of the question is: does anyone know of a constant that can be used to refer to a single day? Or on the flip side, is there just a much better way to do this that I'm missing?

Thanks in advance for any help!

tnowalk
08-02-2008, 02:17 AM
Try this out:

http://boonedocks.net/.../137-Creating-a-Date-Range-Array-with-PHP.html (http://boonedocks.net/mike/archives/137-Creating-a-Date-Range-Array-with-PHP.html)

Just change the format YYYY-MM-DD to what ever you need it to be, hope it helps!

Trevor (http://www.tkm-designs.com)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum