数据库中,某一字段中为空时就显示NULL
但在VB里,要显示这一字段,就会出现实时错误94,无效使用NULL
例如下图:
最后一次记录,没有下机,则注销日期,时间,机器名都是空值NULL
为了保证字段为空时不报错,则出现一个语句来判断该字段是否为空,为空则显示“ ”,否则显示这个字段的内容。
If IsNull(mrc.Fields(5)) Then
.TextMatrix(.Rows - 1, 3) = ""
Else
.TextMatrix(.Rows - 1, 3) = mrc.Fields(5).Value '注销日期
End If
If IsNull(mrc.Fields(6)) Then
.TextMatrix(.Rows - 1, 4) = ""
Else
.TextMatrix(.Rows - 1, 4) = mrc.Fields(6).Value '注销时间
End If
If IsNull(mrc.Fields(7)) Then
.TextMatrix(.Rows - 1, 5) = ""
Else
.TextMatrix(.Rows - 1, 5) = mrc.Fields(7).Value '机器名
End If