H
Howard Kaikow
I'd like to be able to pass a Userform to a Class so the Class can perform
the Userform events.
The difficulty appears to be that when I pass the Userform object to the
class, the Userform Initialize event fires before the class can do anything.
Is there a way around this?
At present, I've tried the following:
In a normal code module, where frmY is the Userform:
Public clsX As X
Public Sub RunTests()
Set clsX = New X
clsX.SetClass frmY
frmY.Show
Set clsX = Nothing
End Sub
And in the Class:
Private WithEvents frmLocal As MSForms.UserForm
Public Sub SetClass(frmIs As MSForms.UserForm)
Set frmLocal = frmIs
End Sub
Private Sub frmLocal_Initialize()
With frmLocal.lst
' Do initialize stuff here
End With
ClearList
End Sub
Private Sub Class_Terminate()
Set frmLocal = Nothing
End Sub
frmLocal_Initialize does not fire, I guess because Userform_Initialize is
firing.
Can I stop the Userform_Initialize event from firing?
Do I need to do so?
the Userform events.
The difficulty appears to be that when I pass the Userform object to the
class, the Userform Initialize event fires before the class can do anything.
Is there a way around this?
At present, I've tried the following:
In a normal code module, where frmY is the Userform:
Public clsX As X
Public Sub RunTests()
Set clsX = New X
clsX.SetClass frmY
frmY.Show
Set clsX = Nothing
End Sub
And in the Class:
Private WithEvents frmLocal As MSForms.UserForm
Public Sub SetClass(frmIs As MSForms.UserForm)
Set frmLocal = frmIs
End Sub
Private Sub frmLocal_Initialize()
With frmLocal.lst
' Do initialize stuff here
End With
ClearList
End Sub
Private Sub Class_Terminate()
Set frmLocal = Nothing
End Sub
frmLocal_Initialize does not fire, I guess because Userform_Initialize is
firing.
Can I stop the Userform_Initialize event from firing?
Do I need to do so?