I have defined one button and one event am raising the event in button click so my question is how to implement that event
Public Event ClickEvent()
Private Sub Command1_Click()
RaiseEvent ClickEvent
End Sub
Assuming your code as posted is in a Form called Form1.
Create a new Form (Form2). Add this code to Form2:
'declare an object and tell vb you want to subscribe to the objects events
Private WithEvents Foo As Form1
Private Sub Form_Load()
'initialise the object
Set Foo = New Form1
'show the Form1 object which has the button on so we have something to click
Foo.Show
End Sub
'when the button is clicked this event is raised
Private Sub Foo_ClickEvent()
MsgBox "Click Event"
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With