vendredi 22 mai 2015

Trying to get checked\unchecked value from all checkboxes

I am making a set of checkboxes through an array. I am able to get the checkboxes into my form without issue. I am having trouble getting the checked\unchecked value from the checkboxes into an excel spreadsheet. On the "if checkbox.checked = true then" line I get the error "MissingMemberException was unhandled" "Public member 'checked' on type 'label' not found." I have searched the web and I am having a hard time finding a solution.

Here is the array:

    X = 30
    Y = 75

    Dim newCheck As CheckBox

    For col As Integer = 1 To TskCnt

        'create a new textbox and set its properties
        newCheck = New CheckBox
        newCheck.Size = New Size(15, 14)
        newCheck.Location = New Point(X, Y)
        newCheck.Name = "Check" & col
        Me.Controls.Add(newCheck)
        Y = Y + 40
    Next

Here is where I am trying to get the values:

    For Each CheckBox In Me.Controls
        If CheckBox.Checked = True Then
            oSheet.Range("B" & RowN).Value = "Completed"
        Else
            oSheet.Range("B" & RowN).Value = "Incomplete"
        End If
        RowN = RowN + 1
    Next




Aucun commentaire:

Enregistrer un commentaire