How to (try)parse a single String to DateTime in “DD/MM/YYYY” format? (VB.Net)

人走茶凉 提交于 2019-12-01 08:38:48

Try this:

Dim date As Datetime = DateTime.ParseExact(_
    yourString, "dd/MM/yyyy", CultureInfo.InvariantCulture)

This will throw an exception if yourString does not match the format you specify. If you do not want an exception in this case then do this:

Dim date As Date    
Date.TryParseExact(dateString, "dd/MM/yyyy", CultureInfo.CurrentCulture, _
                      DateTimeStyles.None, date)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!