2011-01-26 90 views
-2

我在VB.NET应用程序中有2个DateTime值。datetime range vb.net for loop

昏暗的startDate为DATETIME 昏暗的结束日期为DATETIME

现在我想为的startDate和结束日期之间一样,每天一个循环:

对于每一天都当作整数??????? ???

Next

有人有想法吗?

+1

如果你发现自己的解决问题的办法,那么请张贴作为一个答案,并接受它作为正确的答案(你不会收到任何代表,因此这很好)。这样其他人也可以从中受益。 – 2011-01-26 08:38:03

回答

2

C#

for(DateTime CurrentDate = StartDate; 
    CurrentDate < EndDate; 
    CurrentDate = CurrentDate.AddDays(1)) 
{ 
} 

VB.NET

Dim CurrentDate As DateTime = StartDate 
While CurrentDate < EndDate 
    CurrentDate = CurrentDate.AddDays(1) 
End While 
+0

糟糕...我自动在C#中回答。 – BeemerGuy 2011-01-26 08:20:50

+0

感谢这个工程,但我有一个更好的方法,为寻找解决方案的人,看看TimeSpan对象。无论如何感谢 – Vincent 2011-01-26 08:27:51

1
Dim currentDate As Date = startDate 
While currentDate <= endDate 
    'do something with this date...' 
    currentDate = currentDate.AddDays(1) 
End While