大家好,我的项目中的一行代码出现空引用运行时错误,但是如果我断点然后单步执行,一切正常。有什么想法吗
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim checkbox_l As String = "CheckBox"
Dim checkbox_i As string
For i As Integer = 1 To id Step 1
checkbox_i = checkbox_l + i.ToString
Try
If CType(Panel1.Controls(checkbox_i), CheckBox).Checked = True Then
My.Settings.name = Panel1.Controls("CheckBox" & i).Text
Call installer_properties()
Call start_install()
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Next
End Sub
该代码旨在检查是否已选中动态创建的复选框,然后相应地继续前进,但是我在该行中遇到错误
If CType(Panel1.Controls(checkbox_i), CheckBox).Checked = True Then