UserForm Pointers & Class Modules

B

Bart

Hello,

On module level of an UserForm there's a variable declared as a
certain Class (User Defined). When passing a pointer of this UserForm
to a Subroutine in a Module and try to access the variable by this
pointer, it says the Object doesn't support this Property or Method.

Why can't I access the variable by using a pointer of a UserForm?

Example:

[General]
Public myObject as myClass

[Sub]
Public mySub(ByRef myPointer as MSForms.UserForm)
myPointer.myObject.myProperty = "myValue"
End Sub

Regards,
Bart
 
N

NickHK

Bart,
It will work if you pass it like this instead:

Public Sub PassRefTest(SomeForm As YourUserFom)
SomeForm.myObject.myProperty = "myValue"
End Sub

NickHK
 
B

Bart

Thanks again NickHK!

Somewhere I can see the logic of it, but wouldn't ever think of
assigning this kind of Type!

What about passing an other UserForm than 'YourUserForm'? And then
which specifications does this UseForm need to have? Does it minimal
needs to have the Variables declared at module level which eventually
are used in the procedure?

Bart
 
N

NickHK

Yes, basically.
You could try passing a generic Object in the argument, although then you
will lose all Intellisense.

NickHK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top