Dim chcboxes() As CheckBox = {CheckBox1, CheckBox2, CheckBox3}
For i As Integer = 0 To chcboxes.Length
If (chcboxes(i).CheckState = CheckState.Checked) Then
cmd.CommandText = "insert into array_tbl(array_id,answer) values ('" & i & "' , '" & CheckBox1.Text & "')"
cmd.ExecuteNonQuery()
错误是:
array.exe中发生了'System.IndexOutOfRangeException'类型的未处理异常
其他信息:索引超出了数组的范围。
答案 0 :(得分:1)
将For
条件更改为:
For i As Integer = 0 To chcboxes.Length - 1