https://www.excelforum.com/excel-pro...ml#post4382802
https://www.excelforum.com/excel-pro...ml#post4382894
https://www.excelfox.com/forum/showt...ll=1#post24175
Thanks Rory,
Just one last thing to make sure I got it..
Originally Posted by rorya
... That's why the changes weren't being reflected in your code - you were referring to two separate instances of the form......
I was referring originally ( in my Debug check lines ) to
ufResults..
That was not an instance was it, as it is the original ( Blueprint ).... Or is it... In this case....
Alan
_.___________
Rory (Romperstomper) 05-10-2016, 10 May 2016
Yes it is. As soon as you use ufResults for the first time, a new instance of the form is created. It's confusing because you effectively get a variable of the same name as the class. So that instance was not the same as the fm instance. (If you'd added a Debug.Print Userforms.Count line in there, you'd have seen 2 forms)
For a simple demo, in a new workbook, add a blank userform, then add this code and run it:
Code:Sub foobar() Dim fm As UserForm1 Set fm = New UserForm1 ' created an instance of the form MsgBox UserForms.Count ' you'll see 1 here UserForm1.Caption = "Loaded another instance" ' this loaded a new instance of the form and assigned a variable called Userform1 MsgBox UserForms.Count ' so you'll see 2 here End Sub





Reply With Quote
Bookmarks