I am trying to loop between two dates that a user enters but I get the following error: 'For' loop control variable cannot be of type Date'
If I can't use a for loop how can I loop around the two date to create an string array of the month and year between the two dates? I am using asp 1.1 with vb\
Thanks
Hi,
you can use While loop. Simple demonstration to loop day by day
Dim dtStartAs DateTime = DateTime.Now.Date Dim dtEndAs DateTime = dtStart.AddDays(150)Dim dtLoopAs DateTime = dtStartWhile dtLoop <= dtEnd'Do something with dtLoop here 'Response.Write(dtLoop.ToString() & "<br>") dtLoop = dtLoop.AddDays(1)End While
You can of course loop also months, years...or time just as well. It just depends on how you increment the loop date variable.
Thanks
0 comments:
Post a Comment