re-assign a control to new class event handler

RAYLWARD102

Well-known Member
Joined
May 27, 2010
Messages
529
Is it possible?
During control creation, you can assign a class event routing (click, change events.....) to a UserForm control (My method below)
Code:
                Set C1 = New Class1
                Set C1.labelz = LAB


Is there any possibility for re-assigning a control that has already been assigned

Code:
         'Set to label routing 
                Set C1 = New Class1
                Set C1.labelz = LAB

         'After some control has been clicked, re-purpose the control by assigning a new class routing
         Set C1.labelz3 = LAB
 
Working Now!!! yeah. Thanks Norie!
Added Set C1 = New PlatformControls
Code:
Private Sub labelzA_Click()
    MsgBox "test"
    MEM1.Remove labelzA.Name
    With labelzA
        Set C1 = New PlatformControls
        Set C1.labelzB = LAB
        MEM1.Add Item:=C1, Key:=labelzA.Name
    End With
End Sub
Private Sub labelzB_Click()
    MsgBox "sucess"
End Sub

Spoke to soon; the above works when performed from the class member event (Private Sub LabelsA(Click)) The re-assigning of the LabelzA to LabelzB
How to accomplish same task ( re-assigning of the LabelzA to LabelzB) from a public subroutine (not from the class member event)
Tried it from a sub routine and unable to make it work the same way; no errors occur; just doesn't work when performed outside the class.
Here is what I tried

Code:
    Set CNTRL = u1.Controls("FormOptions").Controls("SomeControl")
    
    MEM1.Remove CNTRL.Name
    With CNTRL
        Set C1 = New PlatformControls
        Set C1.labelzB = LAB
        MEM1.Add Item:=C1, Key:=.Name
    End With

This control is contained in userform (u1), frame; hence the formoptions and somecontrol naming
 
Last edited:
Upvote 0

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,224,828
Messages
6,181,213
Members
453,024
Latest member
Wingit77

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