Hi,
I am new programmer in excel/vba and like capture a event click on control created dinamically in userform a runtime execution, follow the code part writed:
Private Sub Image1_Click()
Set mycmd = Frame1.Controls.Add("Forms.image.1", "nome" & i, True)
mycmd.Height = 12
mycmd.Width = 12
mycmd.BackColor = &H4080&
With ThisWorkbook.VBProject.VBComponents("Userform1").CodeModule
linha = .countoflines
MyScript(0) = "Private Sub nome" & i & "_Click()"
MyScript(1) = "set mycmd= frame1.controls(nome" & i & ")"
MyScript(2) = "label2.caption=" & i
.InsertLines linha + 3, MyScript(0)
.InsertLines linha + 5, MyScript(1)
.InsertLines linha + 6, MyScript(2)
.InsertLines linha + 7, "End Sub"
End With
i = i + 1
End Sub
I am new programmer in excel/vba and like capture a event click on control created dinamically in userform a runtime execution, follow the code part writed:
Private Sub Image1_Click()
Set mycmd = Frame1.Controls.Add("Forms.image.1", "nome" & i, True)
mycmd.Height = 12
mycmd.Width = 12
mycmd.BackColor = &H4080&
With ThisWorkbook.VBProject.VBComponents("Userform1").CodeModule
linha = .countoflines
MyScript(0) = "Private Sub nome" & i & "_Click()"
MyScript(1) = "set mycmd= frame1.controls(nome" & i & ")"
MyScript(2) = "label2.caption=" & i
.InsertLines linha + 3, MyScript(0)
.InsertLines linha + 5, MyScript(1)
.InsertLines linha + 6, MyScript(2)
.InsertLines linha + 7, "End Sub"
End With
i = i + 1
End Sub