mercredi 20 juillet 2016

Checkbox event doesn't work in VBA

I defined dynamically checkboxes which added to the userform on runtime.

Sub Userform_Initialize()
  For i = 1 To 4
    Set Chk = Frame4.Controls.Add("Forms.Checkbox.1", "Checkbox" & i)
    With Chk
       .top = 84 + k
       .left = 336
       .Width = 100
       .Height = 18
       .Caption = "Add item"
       .Visible = True
    End With
    k = k + 24
  Next i
End Sub

Public WithEvents Chk As MSForms.CheckBox
Private Sub Chk_Click()
    MsgBox Chk
End Sub

The event doesn't respond. Do anyone have an idea? I need the bool of the checkbox. That means when the user clicked on a dynamic checkbox then I see in the msgbox a "true"




Aucun commentaire:

Enregistrer un commentaire