Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
08-02-2008, 01:25 AM #1
- Join Date
- Aug 2008
- Thanked 0 Times in 0 Posts
Populating an array of dates with a start and an end date. VB.NET 2008
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
Thanks in advance for any help!
08-02-2008, 02:17 AM #2
- Join Date
- Jul 2008
- New York
- Thanked 2 Times in 2 Posts