Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 ASP.NET VB。我正在努力确保一个日期大于另一个日期。
我有以下内容:
For Each row1 In dtDataTable2.Rows If (row1("ActualDate") > row1("DueDate")) Then End If Next
ActualDate 和 DueDate 都是日期。我得到以下信息:
Option Strict on 禁止对象“>”类型的操作数。
如果您将代码更改为:
If (CDate(row1("ActualDate")) > CDate(row1("DueDate"))) Then
它会起作用的。
DataRow 上的默认属性(即 Item 属性)返回的值类型是一个对象,因此您需要将该对象转换为您需要的数据类型。