I am studying form event for VB.NET
My program is loading and setting some of date on the VB.NET form.
I suddenly get System.IndexOutOfRangeException when software switch check box to true
for example, I am using control and for loop to switch check box status I am using control method to looping and searching checkbox in the groupbox
For Each c As Control In GT.SET_MY.Controls
If c.GetType Is GetType(CheckBox) Then
Dim sc As CheckBox = DirectCast(c, CheckBox)
If BW_List(BW_INDEX).Trim = "Y" Then
**sc.Checked = CB.T** ' **ERR POINT**
Tracker = sc.Text
Else
sc.Checked = CB.F
End If
BW_INDEX -= 1
End If
Next
When program is set checkbox to false like " sc.Checked = CB.F". It doesn't have any error
However, when program is set checkbox to true(sc.Checked = CB.T), it returns to System.IndexOutOfRangeException
I am not clearly sure why this happen...
error message is
A first chance exception of type 'System.IndexOutOfRangeException' occurred in Myproject.exe
Step into: Stepping over non-user code 'System.Windows.Forms.Control.WmShowWindow'
Step into: Stepping over non-user code 'System.Windows.Forms.NativeWindow.DebuggableCallback'
Step into: Stepping over non-user code 'System.Windows.Forms.Control.SetVisibleCore'
Step into: Stepping over non-user code 'System.Windows.Forms.Form.SetVisibleCore'
does anybody know why this happen ?
OK
I found major problem of this error
When Software is automatically check or uncheck, it randomly triggers some events in the software and it become cause of error.