jeudi 10 janvier 2019

Debugging VB.NET Studio gets halted

I'm trying to check some CheckBoxes programatically. I read this post to do it. How To Get Control Property by "String Name"?

My code: 1)

Dim FiltrosStr As String = AnswerX.Substring(7)
Dim Filt13() As String = FiltrosStr.Split(",")

If Filt13.Length >= 2 Then
Dim Filt1 = Filt13(0)
Dim Filt3 = Filt13(1)

' Me.Invoke(Sub()
x = 1
For Each XBit As Char In Filt1

    Dim ChkName As String = "Filt" & x.ToString & "xxEvtVerChk"
    'Down here get halted
    Dim ChkX As CheckBox = Me.Controls.Find(ChkName, True).FirstOrDefault()

    If XBit = "1" Then
        ChkX.Checked = True
    Else
        ChkX.Checked = False
    End If
    x += 1
    If x > 6 Then
        Exit For
    End If
Next

2) Also tried

Dim x As Integer
Dim FiltrosStr As String = AnswerX.Substring(7)
Dim Filt13() As String = FiltrosStr.Split(",")

If Filt13.Length >= 2 Then
Dim Filt1 = Filt13(0)
Dim Filt3 = Filt13(1)

' Me.Invoke(Sub()
x = 1
For Each XBit As Char In Filt1

    Dim ChkName As String = "Filt" & x.ToString & "xxEvtVerChk"
    'Down here get halted
    Dim ChkX As CheckBox = CType(Me.Controls(ChkName), CheckBox)

    If XBit = "1" Then
        ChkX.Checked = True
    Else
        ChkX.Checked = False
    End If
    x += 1
    If x > 6 Then
        Exit For
    End If
Next

I just need to check or uncheck some checkboxes that are inside a three level TabPage Form-> TabPage-> TabPage-> TabPage-> GroupBox-> CheckBox

The 12 Check Boxes have almost the same name, only changes one number in the middle of it names.

I don't understand what I doing wrong and why even the IDE get halted. The only way to stop it is by closing the session or restart Windows.




Aucun commentaire:

Enregistrer un commentaire