-- 作者:ajie5211
-- 发布时间:2018/5/15 10:06:00
-- [求助]值不能为空应在哪里增加判断
哪下代码,不定时出错,提示值不能为空,请帮助确认问题在哪里。
Dim nrtrv As WinForm.TreeView = e.Form.Controls("TreeView2") Dim bm As WinForm.TextBox = e.Form.Controls("表名") Dim lmk As WinForm.TextBox = e.Form.Controls("列名") Dim yjdnrs As new List(of String) Dim lm As String = lmk.Value Dim xjds As new List(of String) Dim dtbjdnrs As new List(of String) Dim tbjdnrs As new List(of String) Dim kbpd As Boolean = False \'空白判断 Dim sxpd As Boolean = False \'已筛选判断 Dim xtj As String If Tables(bm.Value).filter > "" Then For Each tbsxlxx As String In tbsxlxxs \'已筛选的取消按钮变色 Dim sjl() As String = tbsxlxx.Split("|") If sjl(0) = bm.Value Then If sjl(1) = lm Then Dim qc As WinForm.Button = e.Form.Controls("取消") qc.BackColor = Color.SkyBlue sxpd = True Else If xtj IsNot Nothing Then xtj = "(" & sjl(2) & ") and " & xtj Else xtj = "(" & sjl(2) & ")" End If End If End If Next End If If xtj Is Nothing Then If Tables(bm.Value).Cols(lm).IsNumeric = True Then dtbjdnrs = Tables(bm.Value).DataTable.GetValues(lm,lm & " is not null and " & lm & " <> 0",lm) Else dtbjdnrs = Tables(bm.Value).DataTable.GetValues(lm,lm & " is not null and " & lm & " <> \'\'",lm) End If Else If Tables(bm.Value).Cols(lm).IsNumeric = True Then dtbjdnrs = Tables(bm.Value).DataTable.GetValues(lm,xtj & " and (" & lm & " Is not null and " & lm & " <> 0)",lm) Else dtbjdnrs = Tables(bm.Value).DataTable.GetValues(lm,xtj & " and (" & lm & " Is not null and " & lm & " <> \'\')",lm) End If End If Dim sxkbpd As Boolean = False For Each r As Row In Tables(bm.Value).Rows If r.IsNull(lm) OrElse r(lm) = Nothing Then kbpd = True sxkbpd = True Else If tbjdnrs.Contains(r(lm)) = False Then tbjdnrs.Add(r(lm)) End If End If Next For Each dtbjdnr As String In dtbjdnrs If sxpd = False Then If tbjdnrs.Contains(dtbjdnr) Then yjdnrs.Add(dtbjdnr) End If Else yjdnrs.Add(dtbjdnr) End If Next If sxpd = False Then Dim ybkbdr As DataRow If Tables(bm.Value).Cols(lm).IsNumeric = True Then ybkbdr = Tables(bm.Value).DataTable.Find(lm & " is null or " & lm & " = 0") Else ybkbdr = Tables(bm.Value).DataTable.Find(lm & " is null or " & lm & " = \'\'") End If If ybkbdr IsNot Nothing Then kbpd = True End If End If If kbpd = True Then yjdnrs.Insert(0,"空白") End If
If e.Sender.Text IsNot Nothing Then For Each yjdnr As String In yjdnrs If yjdnr.Contains(e.Sender.Text.ToLower) OrElse yjdnr.Contains(e.Sender.Text.ToUpper) Then xjds.Add(yjdnr) End If Next End If
nrtrv.StopRedraw() If e.Sender.Text = "" Then nrtrv.Nodes.Clear If yjdnrs.Contains("空白") Then nrtrv.Nodes.Insert("空白",0) nrtrv.Nodes(0).BackColor = Color.Aqua If sxkbpd = True Then If sxpd = True Then nrtrv.Nodes(0).Checked = True End If End If End If For Each yjdnr As String In yjdnrs If yjdnr <> "空白" Then nrtrv.Nodes.Add(yjdnr) If tbjdnrs.Contains(yjdnr) Then If sxpd = True Then nrtrv.Nodes(yjdnr).Checked = True End If End If End If Next Else nrtrv.Nodes.Clear For Each xjd As String In xjds nrtrv.Nodes.Add(xjd) \'If tbjdnrs.Contains(xjd) Then \'If sxpd = True Then nrtrv.Nodes(xjd).Checked = True \'End If \'End If Next End If nrtrv.ResumeRedraw() nrtrv.CollapseAll()
此主题相关图片如下:qq图片20180515100148.jpg

|