Vb.net 如何将字符串转换为mm/dd/yyyy格式
如何将类似“2016年11月17日星期四15:33:56”的字符串更改为mm/dd/yyyy日期格式。我已经尝试过使用内置的VB.NET日期函数Vb.net 如何将字符串转换为mm/dd/yyyy格式,vb.net,Vb.net,如何将类似“2016年11月17日星期四15:33:56”的字符串更改为mm/dd/yyyy日期格式。我已经尝试过使用内置的VB.NET日期函数CDate()以下是一些适用于您给出的日期的代码作为示例 Dim str As String = "15:33:56 Thursday 17th, November 2016" 'Remove the "th" from "17th, since this confuses the parser str = System.Text.RegularExp
CDate()
以下是一些适用于您给出的日期的代码作为示例
Dim str As String = "15:33:56 Thursday 17th, November 2016"
'Remove the "th" from "17th, since this confuses the parser
str = System.Text.RegularExpressions.Regex.Replace(str, "[a-z]{2}(?=,)", String.Empty)
'change the date to mm/dd/yyyy format
str = DateTime.Parse(str).ToString("MM/dd/yyyy")
谷歌搜索了“vb.net date tryparse”,第一个结果是请查看并获取。这将是值得展示你的代码。@muffi-基于这个问题,我怀疑OP是否知道寻找术语“TryParse”,但我同意应该先尝试一个简单的搜索。