Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loop through every minute of a time range 1

Status
Not open for further replies.

chilly442

Technical User
Jun 25, 2008
151
US
I need to loop through every minute of a time range to test against another value. How would I start with EventS, and loop through each minute until EventS = EventE (regardless of how long the duration is)?

I can't get the minute to increment.
This is the format that I use for the times.

Dim EventS As String = Format(MyDate, "MM/dd/yyyy hh:mm")
Dim EventE As String = Format(MyDate, "MM/dd/yyyy hh:mm")

Thanks for the help.
Any help deserves a star.
Chilly442
 
First thing, you don't use a string. You use a DateTime datatype. Here's an example. This starts a loop from the beginning of the current date (midnight) until now.
Code:
        Dim StartDate As DateTime = DateTime.Today
        Dim EndDate As DateTime = DateTime.Now
        Dim s As String = ""
        While StartDate <= EndDate
            s &= StartDate.ToShortTimeString & ControlChars.Tab
            [b]StartDate = StartDate.AddMinutes(1)[/b]
        End While
        MessageBox.Show(s)
 
I was trying to convert the string to an integr add one minute, then change it back to a string. Your code is much cleaner than the 15 lines that I had and still didn't get the result I was looking for.

Thanks for the reply. I'll give your code a try.
Chilly442
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top