Im having difficulties with this code ...
i would so much like to Create an event in the runtime for a control has been created in the runtime as well .... help
Option Explicit Dim i As Integer Dim cmdButton(200) As CommandButton Private Sub cmdButton_Click(i As Integer) MsgBox "hi" End Sub Private Sub Form_Load() For i = 0 To 20 Set cmdButton(i) = Form1.Controls.Add("VB.CommandButton", "newCommandButton" & Me.Controls.Count) With cmdButton(i) .Left = 1000 * i .Top = 1000 .Width = 2000 .Height = 500 .Caption = "Hello" .Visible = True End With Next i End Sub Private Sub Form_Unload(Cancel As Integer) Set cmdButton(i) = Nothing End Sub
you will find the cmdbutton repeats itself fine... but i want to :
when i click on it , gives me a message ... How ?