View Single Post
 
Old 01-31-2018, 12:37 PM
Cosmo Cosmo is offline Windows Vista Office 2007
Competent Performer
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

Ok, apparently I'm even rustier in VBA than I had originally thought. I thought I had everything, but I'm having a problem that I believe I've run into before, but don't remember how to solve.

I'm passing the userForm from one function into a class, and instead of passing the UserForm itself, apparently the object I'm receiving as a parameter is the UserForm.Controls object.
Code:
Function test()
   Dim frm As UserForm
   Set frm = New UserForm1


   AddAsObject (frm)

   AddAsUserForm (frm)
End Function

Function AddAsObject(ByRef frm As Object)
   ' This works because the variable received is a 'Controls' object
End Function

Function AddAsUserForm(ByRef frm As UserForm)
   ' This DOESN'T work because the variable received is NOT a 'UserForm' object
End Function
So, how do I pass the UserForm as a parameter to another function?
Reply With Quote