Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual Basic
H-L Functions
 IsDate Function

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual Basic Language Reference
IsDate Function (Visual Basic)

Returns a Boolean value indicating whether an expression represents a valid Date value.

Public Function IsDate(ByVal Expression As Object) As Boolean
Expression

Required. Object expression.

IsDate returns True if Expression is of the Date Data Type or can be converted to Date; otherwise, it returns False.

The Date data type holds both a date value and a time value. IsDate returns True if Expression represents a valid date, a valid time, or a valid date and time.

The following example uses the IsDate function to determine if several variables represent valid Date values.

Visual Basic
Dim firstDate, secondDate As Date
Dim timeOnly, dateAndTime, noDate As String
Dim dateCheck As Boolean
firstDate = CDate("February 12, 1969")
secondDate = #2/12/1969#
timeOnly = "3:45 PM"
dateAndTime = "March 15, 1981 10:22 AM"
noDate = "Hello"
dateCheck = IsDate(firstDate)
dateCheck = IsDate(secondDate)
dateCheck = IsDate(timeOnly)
dateCheck = IsDate(dateAndTime)
dateCheck = IsDate(noDate)

In the preceding example, IsDate returns True for the first four calls and False for the last call.

Namespace: Microsoft.VisualBasic

Module: Information

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker