Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 变量在它之前使用';已分配了一个值,但现在数据不';t滤波器_Vb.net_Datatable - Fatal编程技术网

Vb.net 变量在它之前使用';已分配了一个值,但现在数据不';t滤波器

Vb.net 变量在它之前使用';已分配了一个值,但现在数据不';t滤波器,vb.net,datatable,Vb.net,Datatable,因此,我有一段代码,可以根据多个条件过滤数据表。其他所有标准都很好,但这些标准都基于文本框。所以代码只是 Dim SubjFilter As String = "Subjects = '" & TxtSubj.Text & " '" 然后与下面代码的底部相同。这样可以很好地打印列表框中的行,但是当我尝试使用单选按钮时,似乎找不到标准。在CSV中,第4列中的每一行都有一条信息,要么是75+,要么是85+,或者其他什么,所以我知道这不是问题所在。没有出现任何错误,只是无法找到该类别

因此,我有一段代码,可以根据多个条件过滤数据表。其他所有标准都很好,但这些标准都基于文本框。所以代码只是

Dim SubjFilter As String = "Subjects = '" & TxtSubj.Text & " '"
然后与下面代码的底部相同。这样可以很好地打印列表框中的行,但是当我尝试使用单选按钮时,似乎找不到标准。在CSV中,第4列中的每一行都有一条信息,要么是75+,要么是85+,或者其他什么,所以我知道这不是问题所在。没有出现任何错误,只是无法找到该类别中的任何内容,或者可能是我在列表框中打印的方式有问题。我现在迷路了,任何一种洞察力都会被感激的

Dim ATARFilter As String
    If RBtn70.Checked = True Or
    Rbtn75.Checked = True Or
    RBtn80.Checked = True Or
    Rbtn85.Checked = True Or
    Rbtn90.Checked = True Or
    Rbtn95.Checked = True Then 'if any of the radiobuttons are checked then the same printing process as before is done

        If RBtn70.Checked = True Then
            ATARFilter = "ATAR = '70+'"
        ElseIf Rbtn75.Checked = True Then
            ATARFilter = "ATAR = '75+'"
        ElseIf RBtn80.Checked = True Then
            ATARFilter = "ATAR = '80+'"
        ElseIf Rbtn85.Checked = True Then
            ATARFilter = "ATAR = '85+'"
        ElseIf Rbtn90.Checked = True Then
            ATARFilter = "ATAR = '90+'"
        ElseIf Rbtn95.Checked = True Then
            ATARFilter = "ATAR = '95+'" 'all of these just set the string value of the filter to be equal to whatever is on the RadioButton
            Dim FilteredRowsATAR As DataRow() = TutorTable.Select(ATARFilter)
            For Each row As DataRow In FilteredRowsATAR
                ListBox1.Items.Add(String.Format("{0},  {1},  {2},  {3},  {4},  {5}", row("Name"), row("Age"), row("Subjects"), row("ATAR"), row("Location"), row("PhNumber")))
            Next
        End If
    End If

只有ElseIf中的最后一个条件包含应用过滤器的代码,您需要将其移出块

Dim ATARFilter As String
    If RBtn70.Checked = True Or
    Rbtn75.Checked = True Or
    RBtn80.Checked = True Or
    Rbtn85.Checked = True Or
    Rbtn90.Checked = True Or
    Rbtn95.Checked = True Then 'if any of the radiobuttons are checked then the same printing process as before is done

        If RBtn70.Checked = True Then
            ATARFilter = "ATAR = '70+'"
        ElseIf Rbtn75.Checked = True Then
            ATARFilter = "ATAR = '75+'"
        ElseIf RBtn80.Checked = True Then
            ATARFilter = "ATAR = '80+'"
        ElseIf Rbtn85.Checked = True Then
            ATARFilter = "ATAR = '85+'"
        ElseIf Rbtn90.Checked = True Then
            ATARFilter = "ATAR = '90+'"
        ElseIf Rbtn95.Checked = True Then
            ATARFilter = "ATAR = '95+'" 'all of these just set the string value of the filter to be equal to whatever is on the RadioButton
        End If

        Dim FilteredRowsATAR As DataRow() = TutorTable.Select(ATARFilter)
        For Each row As DataRow In FilteredRowsATAR
            ListBox1.Items.Add(String.Format("{0},  {1},  {2},  {3},  {4},  {5}", row("Name"), row("Age"), row("Subjects"), row("ATAR"), row("Location"), row("PhNumber")))
        Next
    End If

只有ElseIf中的最后一个条件包含应用过滤器的代码,您需要将其移出块

Dim ATARFilter As String
    If RBtn70.Checked = True Or
    Rbtn75.Checked = True Or
    RBtn80.Checked = True Or
    Rbtn85.Checked = True Or
    Rbtn90.Checked = True Or
    Rbtn95.Checked = True Then 'if any of the radiobuttons are checked then the same printing process as before is done

        If RBtn70.Checked = True Then
            ATARFilter = "ATAR = '70+'"
        ElseIf Rbtn75.Checked = True Then
            ATARFilter = "ATAR = '75+'"
        ElseIf RBtn80.Checked = True Then
            ATARFilter = "ATAR = '80+'"
        ElseIf Rbtn85.Checked = True Then
            ATARFilter = "ATAR = '85+'"
        ElseIf Rbtn90.Checked = True Then
            ATARFilter = "ATAR = '90+'"
        ElseIf Rbtn95.Checked = True Then
            ATARFilter = "ATAR = '95+'" 'all of these just set the string value of the filter to be equal to whatever is on the RadioButton
        End If

        Dim FilteredRowsATAR As DataRow() = TutorTable.Select(ATARFilter)
        For Each row As DataRow In FilteredRowsATAR
            ListBox1.Items.Add(String.Format("{0},  {1},  {2},  {3},  {4},  {5}", row("Name"), row("Age"), row("Subjects"), row("ATAR"), row("Location"), row("PhNumber")))
        Next
    End If

这段代码需要导入System.Linq。检查什么都不说什么都不检查

Private Sub OPCode()
            Dim ATARFilter As String = ""
            Dim rButton As RadioButton = GroupBox1.Controls.OfType(Of RadioButton).FirstOrDefault(Function(r) r.Checked = True)
            If rButton Is Nothing Then
                MessageBox.Show("Please make a selection.")
                Exit Sub
            Else
                ATARFilter = rButton.Text 'or if the exact text cannot not appear
                ' in the text of the radio button then store it in the .Tag property
                'at design time and change code to = CStr(rButton.Tag)
            End If
            Dim FilteredRowsATAR As DataRow() = TutorTable.Select(ATARFilter)
            For Each row As DataRow In FilteredRowsATAR
                ListBox1.Items.Add(String.Format("{0},  {1},  {2},  {3},  {4},  {5}", row("Name"), row("Age"), row("Subjects"), row("ATAR"), row("Location"), row("PhNumber")))
            Next
        End Sub

这段代码需要导入System.Linq。检查什么都不说什么都不检查

Private Sub OPCode()
            Dim ATARFilter As String = ""
            Dim rButton As RadioButton = GroupBox1.Controls.OfType(Of RadioButton).FirstOrDefault(Function(r) r.Checked = True)
            If rButton Is Nothing Then
                MessageBox.Show("Please make a selection.")
                Exit Sub
            Else
                ATARFilter = rButton.Text 'or if the exact text cannot not appear
                ' in the text of the radio button then store it in the .Tag property
                'at design time and change code to = CStr(rButton.Tag)
            End If
            Dim FilteredRowsATAR As DataRow() = TutorTable.Select(ATARFilter)
            For Each row As DataRow In FilteredRowsATAR
                ListBox1.Items.Add(String.Format("{0},  {1},  {2},  {3},  {4},  {5}", row("Name"), row("Age"), row("Subjects"), row("ATAR"), row("Location"), row("PhNumber")))
            Next
        End Sub

撕掉过滤器中的多余空间,
txtsub.Text&“”
应该是
txtsub.Text&“”
。。。我还想把你的
改成
。我被你的意思搞糊涂了,你的额外空间是什么?看起来你的选择只有在Rbtn95为真的情况下才会被应用。从过滤器中去掉额外的空间,
txtsub.Text&“
应该是
txtsub.Text&”
。。。我还想将您的
更改为
。我不明白您所说的“删除额外空间”是什么意思,是什么额外空间?看起来您的选择只有在Rbtn95为真时才会应用。