我打算在出勤时选中已选中但未选中的复选框,但出现在我的代码中。 ''没有为类型'DBNull'定义,而是输入'Boolean'。“...请帮助...您的帮助非常感谢。感谢运算符'='没有为类型'DBNull'定义,而是类型'布尔'。?/
我的代码:
下一页
Dim Present As Integer = 0
Dim Absent As Integer = 0
For a = 0 To Table2___lieDataGridView.RowCount - 1
For b = 0 To Table2___lieDataGridView.ColumnCount - 8
If Table2___lieDataGridView.Rows(a).Cells(b + 5).Value = True Then
Present += 1
Else
Absent += 1
End If
Next
Table2___lieDataGridView.Rows(a).Cells(10).Value = Present
Table2___lieDataGridView.Rows(a).Cells(11).Value = Absent
Present = 0
Absent = 0
Next
您需要检查值是'Nothing'还是'DBNull',如果不是,那么您可以安全地将它转换为'Boolean'并进行比较。 – 2014-09-26 04:01:47
感谢您的评论..我在哪里检查它? – 2014-09-26 04:04:55
请参阅下面的答案。您可以使用内置的[IsDBNull](http://msdn.microsoft.com/zh-cn/library/tckcces5(v = vs.90).aspx)函数 – 2014-09-26 04:07:27