将日期字符串转换为DateTime格式vb.net

Amr*_*har 4 vb.net asp.net datetime-format

我有这个例子,它给了我异常"从字符串x转换为dateTime无效"

这是我验证Datetime的方法.

示例日期字符串:"27/03/1985"

Public Function validateDateColumn(ByRef FieldName As String) As Boolean

    Try
        If IsDate(FieldName) Then
            Dim actualDate As DateTime = CDate(FieldName)
            Dim DtLicExp As DateTime = CDate(actualDate.ToString("d", Thread.CurrentThread.CurrentCulture))
            FieldName = DtLicExp.ToString("MM/dd/yyyy")
            Return True
        End If
    Catch ex As Exception
        'FieldName &= "Format must be MM/dd/yyyy"
        Return False
    End Try

End Function
Run Code Online (Sandbox Code Playgroud)

任何想法来验证这个日期字符串格式到datetime.

我想将此日期"27/03/1985"转换为datetime.

我正在使用asp.net和vb.net.