我在以下几行获得例外
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#
任何人都可以帮忙解决这个问题。
谢谢..
答案 0 :(得分:8)
试试这个
Dim dt As Date = Date.ParseExact("07/15/2014","MM/dd/yyyy", CultureInfo.InvariantCulture);
IF dt > Date.Today Then
'CODE HERE
END IF
查看msdn
上的完整文档答案 1 :(得分:7)
InspectionDate = "07/15/2014"
If DateTime.Parse(InspectionDate) > Date.Today Then
'Here comes my logic etc
'Here comes my logic etc
'Here comes my logic etc
End If
试试这个
答案 2 :(得分:2)
在比较两个日期之前使用TryParse方法
Dim dateValue as Date
InspectionDate = "07/15/2014"
If (Date.TryParse(InspectionDate, dateValue) > Date.Today Then
'your code here
End If
检查MSDN中的metod check the description