The VBA IsDate function returns a Boolean, indicating whether a supplied expression is interpreted as a VBA Date.
The syntax of the function is:
Where the supplied Expression is the expression that you want to test.
The following VBA code provides five different expressions to the VBA IsDate function.
' Test if five different expressions are dates.
Dim isDate1 As Boolean
Dim isDate2 As Boolean Dim isDate3 As Boolean Dim isDate4 As Boolean Dim isDate5 As Boolean
isDate1 = IsDate( 42370 )
' The variable isDate1 is now equal to False.
isDate2 = IsDate( "Jan 1 2016" )
' The variable isDate2 is now equal to True.
isDate3 = IsDate( #1/1/2016# )
' The variable isDate3 is now equal to True.
isDate4 = IsDate( "12:00:00 PM" )
isDate5 = IsDate( "John Smith" )' The variable isDate4 is now equal to True. ' The variable isDate5 is now equal to False. |
The above examples show that the VBA IsDate function returns: