Compare Times Within Listbox

Posts 1–5 of 5 · Page 1 of 1
Compare Times Within Listbox
Hello, anyone know the code for comparing the times inside a list box?
For example:


Listbox1 has this inside of it

========================
2013 21-20 20:20:59 blah blah
2013 21-20 23:20:59 blah blah2
etc.......
========================
How would i compare times inside the listbox and post the difference inside a label?

Using Visual Basic
Fortunately theres a function to do so, try this if you're trying to get the difference between the hours...

The date constructors:
Code:
Dim Date1 As Date = #12/20/2013 8:20:59 PM#
Dim Date2 As Date = #12/20/2013 11:20:59 PM#
And the function in action:
Code:
Label1.Text = DateDif(DateInterval.Hour, Date1, Date2)
Alternatively, you can convert the times to seconds, subtract them and then change them back to the time format.
Quote Originally Posted by Geometrical View Post
Fortunately theres a function to do so, try this if you're trying to get the difference between the hours...

The date constructors:
Code:
Dim Date1 As Date = #12/20/2013 8:20:59 PM#
Dim Date2 As Date = #12/20/2013 11:20:59 PM#
And the function in action:
Code:
Label1.Text = DateDif(DateInterval.Hour, Date1, Date2)
Alternatively, you can convert the times to seconds, subtract them and then change them back to the time format.
You....your a smart one....it's night right now so ill try it tomorrow thanks!
Quote Originally Posted by Geometrical View Post
Fortunately theres a function to do so, try this if you're trying to get the difference between the hours...

The date constructors:
Code:
Dim Date1 As Date = #12/20/2013 8:20:59 PM#
Dim Date2 As Date = #12/20/2013 11:20:59 PM#

And the function in action:
Code:
Label1.Text = DateDif(DateInterval.Hour, Date1, Date2)
Alternatively, you can convert the times to seconds, subtract them and then change them back to the time format.
alright i used your code it slightly works....any ideal on how to put the odd items of the list box in one textbox and the evens in another textbox?
Quote Originally Posted by muteninja View Post
alright i used your code it slightly works....any ideal on how to put the odd items of the list box in one textbox and the evens in another textbox?
I don't think you're able to recognize even or odd numbers from a string, maybe from any variable declared as an integer perhaps.
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us