How to raise an event from vb6 Form to a usercontrol?

140 views Asked by At

I am trying to RaiseEvent from a button, this button is located in a Form. Then the idea is to raise the final even to the usercontrol.

I have tried the next code:

Form1

Dim Sec As Integer
Public Event TestEvent()

Private Sub Command1_Click()
RaiseEvent TestEvent
End Sub

usercontrol

Option Explicit
Dim WithEvents f1 As Form1
Dim f2 As Form2

Private Sub f1_TestEvent()
f2.Show
End Sub

Private Sub UserControl_Initialize()
Set f1 = New Form1
f1.Show
Set f2 = New Form2
End Sub

Form2

No code, it is just to verify if the event is raised.

And unfortunately it is not working as I expect.

I hope my question is clear. Thanks

0

There are 0 answers