Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 如何将字符串转换为mm/dd/yyyy格式_Vb.net - Fatal编程技术网

Vb.net 如何将字符串转换为mm/dd/yyyy格式

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

如何将类似“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.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”,但我同意应该先尝试一个简单的搜索。