Information.IsDate(Object) Método
Definición
Devuelve un valor de tipo Boolean que indica si una expresión representa un valor de Date válido.Returns a Boolean value indicating whether an expression represents a valid Date value.
public:
static bool IsDate(System::Object ^ Expression);
public static bool IsDate (object? Expression);
public static bool IsDate (object Expression);
static member IsDate : obj -> bool
Public Function IsDate (Expression As Object) As Boolean
Parámetros
- Expression
- Object
Obligatorio.Required. Expresión Object.Object expression.
Devoluciones
Devuelve un valor de tipo Boolean que indica si una expresión representa un valor de Date válido.Returns a Boolean value indicating whether an expression represents a valid Date value.
Ejemplos
En el ejemplo siguiente se usa la IsDate función para determinar si varias variables representan valores válidos DateTime .The following example uses the IsDate function to determine if several variables represent valid DateTime values.
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)
En el ejemplo anterior, IsDate devuelve True para las cuatro primeras llamadas y False para la última llamada.In the preceding example, IsDate returns True for the first four calls and False for the last call.
Comentarios
IsDate Devuelve True si Expression es del DateTime tipo de datos o se puede convertir en él; de lo contrario, devuelve False .IsDate returns True if Expression is of the DateTime data type or can be converted to it; otherwise, it returns False.
El DateTime tipo de datos contiene un valor de fecha y un valor de hora.The DateTime data type holds both a date value and a time value. IsDate Devuelve True si Expression representa una fecha válida, una hora válida o una fecha y hora válidas.IsDate returns True if Expression represents a valid date, a valid time, or a valid date and time.