Let's say I have a userform called MyUserForm that I use like
Dim form as MyUserForm
Set form = New MyUserForm
form.SomeVar = "Hi"
form.Show ' Displays "Hi" somewhere on the form
and all is fine and dandy. But the following, and this is what strikes me as odd, works as well:
MyUserForm.SomeVar = "Hi"
MyUserForm.Show
which looks like there's some implicitly declared object MyUserForm whose type is precisely the class MyUserForm! What is VBA really doing here? What are the rules governing this strange idiom? Thank you
MyUserForminstances and then callMyUserForm.Showand you will discover the hierarchy. One of the twoMyUserFormis the active userform and you can reference it byMyUserForm.<whatever>but it's bad practice when you have more than one userform to call it using class name. It's better and recommended to always use a variable name that stores reference to the specific instance.