Date.parseexact错误即将到来 [英] Date.parseexact error coming

查看:81
本文介绍了Date.parseexact错误即将到来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我收到此错误字符串未被识别为有效的DateTime。}



for



Dim lvwDateString As String =01/01/2004 12:01:01 AM

Dim lvwDate As Date = Date.ParseExact(lvwDateString, dd / MM / yyyy HH:mm:ss tt,没什么)



我尝试了什么:



之前它工作正常,但想想从windows7切换到10后出现这个错误

解决方案

这可能是约会机器上的/时间设置:格式字符串中的'/'和':'不代表文字字符,但是日期和时间分隔字符为当前区域设置定义 - 这意味着它可能期望01-01-2004 12.01 .01 AM并因此抛出异常。

尝试转义分隔符,看看是否修复它:

  Dim  lvwDate 作为 日期 = 日期 .ParseExact(lvwDateString,  dd \ / MM \ / yyyy HH \:mm \:ss tt没有


Hi all
I'm getting this error String was not recognized as a valid DateTime."}

for

Dim lvwDateString As String = "01/01/2004 12:01:01 AM"
Dim lvwDate As Date = Date.ParseExact(lvwDateString, "dd/MM/yyyy HH:mm:ss tt", Nothing)

What I have tried:

previously it was working fine but think so that after switching from windows7 to 10 this error has occured

解决方案

It's probably the date / time settings on the machine: '/' and ':' in a format string do not represent literal characters, but the date and time separation characters defines for the current locale - which means it could be expecting "01-01-2004 12.01.01 AM" and throwing an exception as a result.
Try escaping your separators, and see if that fixes it:

Dim lvwDate As Date = Date.ParseExact(lvwDateString, "dd\/MM\/yyyy HH\:mm\:ss tt", Nothing)


这篇关于Date.parseexact错误即将到来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆