Subclasses of UserForm Controls?

djr8yk

Board Regular
Joined
May 19, 2015
Messages
58
Is it possible to create a subclass of a UserForm Control, like a CheckBox?
I want to have a CommandButton that is somehow linked with an array of CheckBoxes. I'm dynamically creating some CommandButtons and CheckBoxes, and some of the boxes must be checked before the button can be pressed. Any idea how to create this subclass?
Thanks
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Just to be picky and to help your googling, subclassing isn't what you're after. You're just grouping controls and handling the events they raise as given in the example by Jerry.

Note: Doug's code is good, but he's created a circular reference that he hasn't cleaned up which has created a memory leak. In most languages the garbage collector will correctly resolve these, however the VBA/VB6 garbage collector is poor and cannot so this is one of the very rare times it's actually required to set objects to nothing
 
Last edited:
Upvote 0
Thanks guys! Turned out I messed something else up in my program so I likely won't get to really use this link until Tuesday, but I appreciate the help and the link!
 
Upvote 0
Note: Doug's code is good, but he's created a circular reference that he hasn't cleaned up which has created a memory leak.

Dang, Kyle, that never occurred to me. I generally avoid child classes because I don't want to have to deal with their tendency to point at their parents, who are pointing back at them, but it looks like that's just what I've done here.

I'll go back and edit the post and point to this comment, unless you are inclined to comment yourself with a proposed correction. If so, I'd be most grateful. Thanks in any case.
 
Upvote 0
Any of you might be able to answer this, but Doug especially, what did you mean at that link when you wrote the following:
Code:
 For Each ctl In Me.grpmemberControls.Controls
What is "grpmemberControls"? It's never mentioned anywhere else in the post and I was curious, because that seems to be the only part (hopefully) that I'm stuck on with incorporating your technique into my code.
I thought maybe it was in relation to the GroupName property of Checkbox, but I don't think that's it.
Thank you!
 
Upvote 0
It's the name of the frame that the checkboxes are in.

Oops, I meant to post some code for this and forgot, I'll get on it tomorrow!
 
Upvote 0
OH! Whoops that went over my head, didn't even realize they were in frames. Thank you Kyle.
 
Upvote 0

Forum statistics

Threads
1,215,388
Messages
6,124,658
Members
449,177
Latest member
Sousanna Aristiadou

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top