VBA Static Classes!?

JSA715

Active Member
Joined
Aug 3, 2008
Messages
254
New to using classes in VBA, but is it possible to create a static class?

If not, is it possible to create a 'public' object for every control in a single userform to utilize instead of having to create a new object in every event needed?

Example two radio buttons represent two choices a user can make. The click event submits the choice to thing.choice.

The only way it seems I can submit the choice to the object is something like this:

Code:
Set thing = new classthing
thing.choice = "This Choice"

However, if I do that, all other changes made to the properties are lost since its recreating the object...what am I missing?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
public NewClassThing

private Sub OptionButton1_Click
NewClassThing="ThisChoice"
end sub

private Sub OptionButton2_Click
NewClassThing="ThatChoice"
end sub
 
Upvote 0

Forum statistics

Threads
1,215,236
Messages
6,123,798
Members
449,127
Latest member
Cyko

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