469,125 Members | 1,629 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,125 developers. It's quick & easy.

String convert to date

I'm working on an assignment that requires I loop through a list box with time strings (ex: 1:38 PM, 1:40 PM etc.)

I need a time to compare the current time and the time in the list box and if the current time is greater I have a message box appearing.

I can't get the message box to appear after the timer increments (my timer is anabled at 60000 interval).

--This is the code structure I have so far but it's not working.

I need the If statement to compare the current time and the times in the list box IN **Short Time format**. Any suggestions?

For i = lstTime.Items.Count - 1 To 0 Step 1

If CDate(Now.Date.ToShortTimeString) > Convert.ToDateTime(lstTime.Items(i)) Then
MessageBox.Show("Time has elapsed")
End If
Oct 9 '06 #1
1 2344
1,646 1GB
You can use the DateDiff() function

DateDiff("s", Date1, Date2)

This function returns 0 if both times are equal
A positive integer if Date2 is later than Date1 in seconds
A negative integer if Date2 is earlier than Date1 in seconds
Oct 11 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Hector A | last post: by
22 posts views Thread by Simon Says | last post: by
11 posts views Thread by jwf | last post: by
1 post views Thread by jwf | last post: by
8 posts views Thread by deepak_kamath_n | last post: by
5 posts views Thread by =?Utf-8?B?emlubw==?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.