Mega Code Archive
Converts string to DateTime equivalent and returns a value that indicates whether the conversion succeeded
Imports System
Imports System.Globalization
Imports Microsoft.VisualBasic
Public Class SamplesDTFI
Public Shared Sub Main()
Dim dateStrings() As String = {"05/01/2009 14:57:32.8", "2009-05-01 14:57:32.8", _
"Fri, 15 May 2009 20:10:57 GMT"}
Dim dateValue As Date
For Each dateString As String In dateStrings
If Date.TryParse(dateString, dateValue) Then
Console.WriteLine(" Converted '{0}' to {1} ({2}).", dateString, _
dateValue, dateValue.Kind)
Else
Console.WriteLine(" Unable to parse '{0}'.", dateString)
End If
Next
End Sub
End Class