Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.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 日期-时间-字符串转换_Vb.net - Fatal编程技术网

Vb.net 日期-时间-字符串转换

Vb.net 日期-时间-字符串转换,vb.net,Vb.net,我必须将字符串转换为日期时间 字符串数据的格式如下:2013年6月13日。8:06:36 守则: Dim pDate As String pDate = TextBox16.Text Dim pro_Date As DateTime = DateTime.ParseExact(pDate, "DD.M.YYYY. hh24:mm:ss", CultureInfo.InvariantCulture) 我得到的错误是:字符串未被识别为有效的日期时间 如何转换?格式字符串区分大小写,因此“DD.M.

我必须将字符串转换为日期时间

字符串数据的格式如下:2013年6月13日。8:06:36

守则:

Dim pDate As String
pDate = TextBox16.Text
Dim pro_Date As DateTime = DateTime.ParseExact(pDate, "DD.M.YYYY. hh24:mm:ss", CultureInfo.InvariantCulture)
我得到的错误是:字符串未被识别为有效的日期时间


如何转换?

格式字符串区分大小写,因此“DD.M.YYYY”不起作用。此外,24小时时钟是大写的
H
而不是“hh24”。您需要一个
H
,因为
8:06:36
在小时内没有前导零

Dim pro_Date As DateTime = DateTime.ParseExact(pDate, "dd.M.yyyy. H:mm:ss", CultureInfo.InvariantCulture)
更多信息请参见