473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

String convert to date

Hi,
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
Next
Oct 9 '06 #1
1 2414
willakawill
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

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

Similar topics

2
by: Hector A | last post by:
Hi I'm trying to convert a string that already looks like a date to a date that I can use when I pass it from java to the database. I receive the date in format yyyy-mm-dd and I need it to be a...
1
by: faktujaa | last post by:
Hi, I have date in a string format like string strDate = "110204". Now i want to convert this string to MM/dd/yyyy format. How do i do this???? I used string.Format(strDate, "MM/dd/yyyy") but no...
16
by: PK9 | last post by:
I have a string variable that holds the equivalent of a DateTime value. I pulled this datetime from the database and I want to strip off the time portion before displaying to the user. I am...
10
by: Kim Hellan | last post by:
I have a simple string in the format "DD-MM-YY hh:mm:ss", that I need to convert to a DateTime value. I know this is a standard problem, but please don't just link to all the MSDN pages regarding...
22
by: Simon Says | last post by:
Dear all, I have the following: dim tmpString as String = "11/21/2004 07:55:33" dim tmpDate as Date = CDate(tmpString) But I keep getting <cast from string "11/21/2004 07:55:33" to type...
1
by: abcabcabc | last post by:
I write an application which can let user define own date format to input, How to convert the date string to date value with end-user defined date format? Example, User Defined Date Format as...
11
by: jwf | last post by:
I am writing a NON MFC C++ application (Plug-in for a 3rd party DB system). The application is designed to synchronise data between MS Outlook and the DB system. I am using smart pointers for the...
1
by: jwf | last post by:
This question continues on from a previous post "DATE to string" but I think it deserves a new thread. In my previous post I was trying to convert a DATE to string in a NON MFC C++ application...
8
by: deepak_kamath_n | last post by:
Hello, I have the following scenario: 1. My application receives the date from another application as a string 2. The other application is running in a different time zone as compared to my...
5
by: =?Utf-8?B?emlubw==?= | last post by:
I need to convert a string as: "DEC 18 2007 2:49:40:783PM" to a date. This value is sent by SQL server as :select convert(varchar(30), creationDate, 109) from ... ... . I tried : Dim dt As...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.