Determine if a Value is a Valid Time

Dates and Math
Jim Pragit and Rick Rothstein

Version Compatibility:

More information:
This is one of two examples on the site that checks a value to determine if it is a valid time, the other is at The two versions differ in the following ways:
  • The other version relies on the IsDate function. Therefore, it will accept a value such as "13:33 PM" as a valid time. This version is more stringent and would reject "13:33 PM" as valid (though it would accept "1:33 PM").
  • Because the other version relies on the IsDate function, it takes into account international settings, whereas this version is designed as a stringent check of values on systems in which time values conform to the default American English Regional settings.
Both versions have their use, depending on the situation, so you should choose the one you need.

Instructions: Copy the declarations and code below and paste directly into your VB project.