changing an object behavior at runtime

How do I change, for example, the behavior (the code) of an onclick event at runtime?
Or how do I set the behavior of button created dinamically at runtime?

ex.:
Private Sub Command1_Click()
Form1.Controls.Add "VB.CommandButton", "btnObj"
With Form1!btnObj
.Visible = True

End With

End Sub
And now how do i programm the events?

Comments

  • : How do I change, for example, the behavior (the code) of an onclick event at runtime?
    : Or how do I set the behavior of button created dinamically at runtime?
    :


    check this

    : ex.:
    Private withevents cm as CommandButton

    : Private Sub Command1_Click()
    : set cm= Form1.Controls.Add ("VB.CommandButton", "btnObj")
    : With Form1!btnObj
    : .Visible = True
    :
    : End With
    :
    : End Sub
    : And now how do i programm the events?
    :
    Private Sub cm_Click()
    MsgBox "This is dynamic (but not)"
    End Sub
  • Public WithEvents cm As CommandButton
    Private Sub Command1_Click()
    Set cm = Form1.Controls.Add("VB.CommandButton", "Form1")
    With Form1!Form1
    .Visible = True
    End With
    End Sub


    Private Sub cm_click()
    'Events
    End Sub

    : : How do I change, for example, the behavior (the code) of an onclick event at runtime?
    : : Or how do I set the behavior of button created dinamically at runtime?
    : :
    :
    :
    : check this
    :
    : : ex.:
    : Private withevents cm as CommandButton
    :
    : : Private Sub Command1_Click()
    : : set cm= Form1.Controls.Add ("VB.CommandButton", "btnObj")
    : : With Form1!btnObj
    : : .Visible = True
    : :
    : : End With
    : :
    : : End Sub
    : : And now how do i programm the events?
    : :
    : Private Sub cm_Click()
    : MsgBox "This is dynamic (but not)"
    : End Sub
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories