Date.Today Then 'Here -6ren">
gpt4 book ai didi

asp.net - cType : string to date throwing InvalidCastException (ASP) (VB. NET)

转载 作者:行者123 更新时间:2023-12-01 06:12:12 24 4
gpt4 key购买 nike

我在以下几行遇到异常

InspectionDate = "07/15/2014"
If CType(InspectionDate, Date) > Date.Today Then

'Here comes my logic etc
'Here comes my logic etc
'Here comes my logic etc

End If

当我调试时,我看到 Date.Today = #7/15/2014#

任何人都可以帮忙解决这个问题。

谢谢..

最佳答案

像这样尝试

Dim dt As Date = Date.ParseExact("07/15/2014","MM/dd/yyyy", CultureInfo.InvariantCulture); 
IF dt > Date.Today Then
'CODE HERE
END IF

msdn 查看完整文档

关于asp.net - cType : string to date throwing InvalidCastException (ASP) (VB. NET),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24750268/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com