|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
For loop variable dateHi, all,
I try to use Date as For Loop variable, but it said date cannot be used to For Loop vaiable, anyone has any iead? Thanks, Martin1 "martin1" <mart***@discussions.microsoft.com> schrieb: \\\> I try to use Date as For Loop variable, but it said date cannot be used to > For Loop vaiable, anyone has any iead? Dim StartDate As Date = ... Dim EndDate As Date = ... Dim DaysCount As Integer = (EndDate - StartDate).TotalDays Dim CurrentDate As Date = StartDate For i As Integer = 1 To DaysCount ... CurrentDate = CurrentDate.AddDays(1) Next i /// -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> Thank you. Wagner!
Show quoteHide quote "Herfried K. Wagner [MVP]" wrote: > "martin1" <mart***@discussions.microsoft.com> schrieb: > > I try to use Date as For Loop variable, but it said date cannot be used to > > For Loop vaiable, anyone has any iead? > > \\\ > Dim StartDate As Date = ... > Dim EndDate As Date = ... > Dim DaysCount As Integer = (EndDate - StartDate).TotalDays > Dim CurrentDate As Date = StartDate > For i As Integer = 1 To DaysCount > ... > CurrentDate = CurrentDate.AddDays(1) > Next i > /// > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://dotnet.mvps.org/dotnet/faqs/> > > As Armin has written to you already in past.
Put on Option Strict in top of your program. Beside that do I not see the purpose of your construction. Cor Show quoteHide quote "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht news:udMh5rYFHHA.420@TK2MSFTNGP06.phx.gbl... > "martin1" <mart***@discussions.microsoft.com> schrieb: >> I try to use Date as For Loop variable, but it said date cannot be used >> to >> For Loop vaiable, anyone has any iead? > > \\\ > Dim StartDate As Date = ... > Dim EndDate As Date = ... > Dim DaysCount As Integer = (EndDate - StartDate).TotalDays > Dim CurrentDate As Date = StartDate > For i As Integer = 1 To DaysCount > ... > CurrentDate = CurrentDate.AddDays(1) > Next i > /// > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://dotnet.mvps.org/dotnet/faqs/> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb: Well, I have not tested the snippet. Simply replace 'TotalDays' with > As Armin has written to you already in past. > > Put on Option Strict in top of your program. 'Days'. > Beside that do I not see the purpose of your construction. Huh? Re-read the OP's question and check out his reply to my answer.-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> Wagner wrote:
> Huh? Re-read the OP's question and check out his reply to my answer. Yes I did already the OP was asking.> I try to use Date as For Loop variable You give back an answer with an integer variable.I would as well be shocked and give back a reply with. >Thank you. Wagner! If I was really glad with your answer I would write.Thank you Herfried. Cor Show quoteHide quote "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht news:ed4gyshFHHA.3304@TK2MSFTNGP05.phx.gbl... > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb: >> As Armin has written to you already in past. >> >> Put on Option Strict in top of your program. > > Well, I have not tested the snippet. Simply replace 'TotalDays' with > 'Days'. > >> Beside that do I not see the purpose of your construction. > > Huh? Re-read the OP's question and check out his reply to my answer. > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://dotnet.mvps.org/dotnet/faqs/> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb: Well, think why...>> I try to use Date as For Loop variable > > You give back an answer with an integer variable. > I would as well be shocked and give back a reply with. You know that "Herfried" is my first name. This may be different in the > >>Thank you. Wagner! > > If I was really glad with your answer I would write. > > Thank you Herfried. culture the OP is coming from. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> Martin,
In my idea no problem, but keep in mind date datetime is not a collection of dates. It is just a structure with in it a property ticks that starts at the beginning of a virtual start of the gregorian calendar (the exact point does not exist because that calendar is created after that point). However to do what you say is easy. \\\ Dim dates() As DateTime = {Now, Now.AddDays(10), Now.AddDays(20)} For Each dtm As DateTime In dates MessageBox.Show(dtm.ToString) Next /// I hope this helps, Cor Show quoteHide quote "martin1" <mart***@discussions.microsoft.com> schreef in bericht news:FA08F9A6-2F4A-4913-BA08-E08091403B58@microsoft.com... > Hi, all, > > I try to use Date as For Loop variable, but it said date cannot be used to > For Loop vaiable, anyone has any iead? > > Thanks, > Martin1
Changing Color of Textbox on Hover
Offline application for reporting and collect data Best Approach When Saving a New Project Manage DataBase No Response Redirect but something like Response Forward? Disable sort on specific columns with VB.NET datagrid How do you start an assembly dynamically with constructors Changing Color of TextBox on Hover - With Correct Examples!!! SyncLock Required? Error in displaying data grid |
|||||||||||||||||||||||