Parse date-only value without leading zero in month using "d" format.
Imports System.Globalization
Module MainClass
Public Sub Main()
Dim dateString, format As String
Dim result As Date
Dim provider As CultureInfo = CultureInfo.InvariantCulture
dateString = "6/15/2010"
Try
result = Date.ParseExact(dateString, format, provider)
Console.WriteLine("{0} converts to {1}.", dateString, result.ToString())
Catch e As FormatException
Console.WriteLine("{0} is not in the correct format.", dateString)
End Try
End Sub
End Module
Related examples in the same category