listview 增加数据时null 报错怎么办。

feicui999 2009-08-01 09:23:38
listview 增加数据时null 报错怎么办。

代码如下:
addlist.SubItems(8) = rs.Fields("维修项目")

rs.Fields("维修项目")=NULL
程序运行到空数据行就推出报错,我怎么处理能让LISTVIEW识别空数据?谢谢高手回答!
...全文
143 5 打赏 收藏 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
slowgrace 2009-08-01
  • 打赏
  • 举报
回复
试试这样做:

addlist.SubItems(8) = rs.Fields("维修项目") & ""
feicui999 2009-08-01
  • 打赏
  • 举报
回复
对兄弟的问题这么热心回答了。一样给分。谢了。
feicui999 2009-08-01
  • 打赏
  • 举报
回复
'测试数据集为NULL的字段置空值给LISTVIEW
If IsNull(rs.Fields("维修项目")) Then
' MsgBox "=null"
wxxm = " "
addlist.SubItems(8) = wxxm
Else
' MsgBox "<>null"
addlist.SubItems(8) = rs.Fields("维修项目")
End If
我刚学习了下。这样最好。你正好也学习啊。呵呵!
dingyanwei 2009-08-01
  • 打赏
  • 举报
回复
整反了
dim s as string

s=""
on error resume next
s=rs.Fields("维修项目")
if s="" then
addlist.SubItems(8) = "空的"
else
addlist.SubItems(8)=s
end if
dingyanwei 2009-08-01
  • 打赏
  • 举报
回复
用错误处理,我常用以下方法,但感觉不太好。
dim s as string

s=""
on error resume next
s=rs.Fields("维修项目")
if s="" then
addlist.SubItems(8) = s
else
addlist.SubItems(8)="空的"
end if

1,453

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧