ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Qualifying OptionButton with ro without MSForms (https://www.excelbanter.com/excel-programming/322007-qualifying-optionbutton-ro-without-msforms.html)

augustus

Qualifying OptionButton with ro without MSForms
 
Hi,

i am learning Class Module now, could someone tell me what's the different
between the following:

Public WithEvents OptionGroup As OptionButton

and

Public WithEvents OptionGroup As MSForms.OptionButton

ie, with and without the MSFOrms???

In addition, could someone please let me know where I can find more info on
Class Modules?

Thanks
Augustus

Markus Scheible[_2_]

Qualifying OptionButton with ro without MSForms
 
Hi Augustus,


what's the different
between the following:

Public WithEvents OptionGroup As OptionButton

and

Public WithEvents OptionGroup As MSForms.OptionButton



There is no difference, the point is that you have a
closer definition for OptionButton if you write
MSForms.OptionButton because herewith you give the
connection that OptionButton is a part of the Forms system
within Excel. That could be helpful for a correct
definition for Excel in some cases... If you do not
exactly know where your data type is included, use the
Object Browser (use F2 within the VBA Editor) and search
for the data type... then you can find out where it is
defined within excel.

Best

Markus


ie, with and without the MSFOrms???

In addition, could someone please let me know where I can

find more info on
Class Modules?

Thanks
Augustus
.


Rob Bovey

Qualifying OptionButton with ro without MSForms
 
"Markus Scheible" wrote in message
...
what's the different
between the following:
Public WithEvents OptionGroup As OptionButton
and
Public WithEvents OptionGroup As MSForms.OptionButton


There is no difference, the point is that you have a
closer definition for OptionButton if you write
MSForms.OptionButton because herewith you give the
connection that OptionButton is a part of the Forms system
within Excel. That could be helpful for a correct
definition for Excel in some cases... If you do not
exactly know where your data type is included, use the
Object Browser (use F2 within the VBA Editor) and search
for the data type... then you can find out where it is
defined within excel.


Hi Markus,

Actually, in the context of a WithEvents class module it's critical that
you prefix the OptionButton object name with the MSForms type library. This
is because there is a hidden object with the name OptionButton in the Excel
type library (right-click in the Object Browser and choose Show Hidden
Members).

Because the Excel type library always comes before the MSForms type
library in the Tools/References list, if you only specify OptionButton VBA
will always resolve it as the Excel object rather than the MSForms object.
Since the Excel object doesn't support events, the code will fail.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm





All times are GMT +1. The time now is 12:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com