O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

IsDate Function

Class

Microsoft.VisualBasic.Information

Syntax

IsDate(expression)
expression (required; any)

Expression containing a date or time

Return Value

Boolean indicating whether the expression can be converted to a Date

Description

Determines if an expression is of type Date or can be converted to type Date

Rules at a Glance

  • Returns True if and only if expression is of type Date or can be converted to type Date.

  • Uninitialized date variables also return True.

Programming Tips and Gotchas

  • IsDate uses the locale settings of the current Windows system to determine if the value held within the variable is recognizable as a date. Therefore, what is a legal date format on one machine may fail on another.

  • IsDate is particularly useful for validating data input. However, don’t use IsDate in the VB text box control’s Change event. The Change event is fired with every keystroke, which means that when the user starts to enter the date, chances are that the date will be invalid until the point at which the user has completed the data entry.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required