Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.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 progressbar上未处理错误NullReferenceException_Vb.net - Fatal编程技术网

Vb.net progressbar上未处理错误NullReferenceException

Vb.net progressbar上未处理错误NullReferenceException,vb.net,Vb.net,因此,错误首先发生在progressbar.visible=True。即使我删除它,错误也会发生在它下面的行上。你能告诉我怎么了吗 当用户选择列表框菜单时,就会发生这种情况。假设我有选项A和B。我怀疑progressbar对象名有输入错误。请检查拼写。您的代码中没有任何错误 除此之外,, 我建议您在指定progressbar最大值之前检查行数>0 问候我确实检查了你上面说的所有内容,一切都很好。只有当我使用listbox1.SelectecItem时,问题才出现。当我切换到listbox1.Se

因此,错误首先发生在progressbar.visible=True。即使我删除它,错误也会发生在它下面的行上。你能告诉我怎么了吗


当用户选择列表框菜单时,就会发生这种情况。假设我有选项A和B。

我怀疑progressbar对象名有输入错误。请检查拼写。您的代码中没有任何错误

除此之外,, 我建议您在指定progressbar最大值之前检查行数>0


问候

我确实检查了你上面说的所有内容,一切都很好。只有当我使用listbox1.SelectecItem时,问题才出现。当我切换到listbox1.SelectedValue时,没有出现错误,你知道为什么吗??
    Public Sub GetStationDataFromDatabase()

    Dim StationTable As New DataTable
    StationTable.TableName = "Station"


    Dim Counter As Integer
    Dim SqlString As String
    Dim OperStaRow As DataRow
    Counter = 0

    ProgressBar.Visible = True
    ProgressBar.Minimum = 1
    ProgressBar.Maximum = LocalDataSet.Tables("OR").Rows.Count
    ProgressBar.Value = 1
    ProgressBar.Step = 1
    For Each OperStaRow In LocalDataSet.Tables("OR").Rows
        SqlString = "JUST SOME STRING HERE"

        ExecuteSqlCommand(SqlString, StationTable)
        ProgressBar.PerformStep()
        ProgressBar.Refresh()
        Counter = Counter + 1

        If Counter Mod 20 = 0 Then
            Application.DoEvents()  
        End If
    Next

End Sub