Foxtable(狐表)用户栏目专家坐堂 → [求助]值不能为空应在哪里增加判断


  共有1850人关注过本帖树形打印复制链接

主题:[求助]值不能为空应在哪里增加判断

帅哥哟,离线,有人找我吗?
ajie5211
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:815 积分:5616 威望:0 精华:1 注册:2015/11/28 14:00:00
[求助]值不能为空应在哪里增加判断  发帖心情 Post By: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
图片点击可在新窗口打开查看

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/5/15 10:40:00 [只看该作者]

要判读字符串是不是空格字符串,如

 

    For Each yjdnr As String In yjdnrs
        If yjdnr > "" AndAlso 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


 回到顶部