IsDate Function

See Also24GVZPA              Example1XR59LT>Low

Returns a value indicating whether or not a Variant8PHEAW3 argument can be converted to a date.




The argument variant can be any Variant expression of VarType7A68ZTZ 7 (Date) or of VarType 8 (String).  The IsDate function returns True if the Variant can legally be converted to a date; otherwise, it returns False.  The range of valid dates is January 1, 100 A.D. through December 31, 9999 A.D.

See Also

CVDate Function3E784K

IsEmpty Function2K1M5H0

IsNull Function9BAKWR

IsNumeric Function1MXC66A

VarType FunctionXRZH1Y

IsDate Function Example

The example evaluates TestVar to determine whether it can legally be converted to a numeric data type and displays an appropriate message.  To try this example, paste the code into the Declarations section of a form.  Then press F5 and click the form.


Sub Form_Click ()

   Dim TestVar                           ' Declare variable.

   TestVar = InputBox("Enter a string you'd like displayed as a date.")

   If IsDate(TestVar) Then               ' Test variable.

      MsgBox "The date is: " & Format(CVDate(TestVar),"dddddd")


      MsgBox "What you entered doesn't make sense as a date."

   End If

End Sub