![]() |
Attribute statements of VBA Classes
How are we all today,
I know that I can set the Value property as the default property for a class using: Attribute Value.VB_UserMemId = 0 (see http://www.cpearson.com/excel/DefaultProperty.htm, if you would like to know how to do this. Thanks Chip!) And i know that i can set up an enumrator, NewEnum, for a class using: Attribute NewEnum.VB_UserMemId = -4 But does anyone know where i can find documentation on these attribute statements. If this is possible in VBA then what else am I missing? Thanks, Gogza |
Attribute statements of VBA Classes
Gogza,
I have not seen much on this, but there is so,ething like: Public Property Get Text() As String Attribute Text.VB_Description = "Gets/sets the text displayed in the column header." Attribute Text.VB_UserMemId = 0 Attribute Text.VB_MemberFlags = "200" Not sure what the "200" signifies. At a guess, download some complex VB6 classes/collection etc from the web and look at them in a text editor. You may get lucky at picking up something new. I'll have a look with my VB6 when I'm in the office tomorrow. NickHK "gogza" egroups.com... How are we all today, I know that I can set the Value property as the default property for a class using: Attribute Value.VB_UserMemId = 0 (see http://www.cpearson.com/excel/DefaultProperty.htm, if you would like to know how to do this. Thanks Chip!) And i know that i can set up an enumrator, NewEnum, for a class using: Attribute NewEnum.VB_UserMemId = -4 But does anyone know where i can find documentation on these attribute statements. If this is possible in VBA then what else am I missing? Thanks, Gogza |
Attribute statements of VBA Classes
Hi Gogza,
Not sure why it's not documented in VBA, in VB it's not only documented but there's a dialog to apply various attributes. Copied below is the VB help page without the image of the dialog. Should give an idea as to what else is available, Apart from the simple ones I don't know if all work and/or safely in VBA. Some do though, eg add a description to the property for viewing in the Object browser, following Chip's example. Property Get Value() As Long Attribute Value.VB_Description = "my value description" Attribute Value.VB_UserMemId = 0 Value = pValue End Property For those with VB, put cursor in a class containing 'one or more procedures defined', Tools Procedure Attributes... Regards, Peter T [page top] Procedure Attributes Dialog Box [an image of the dialog here] Allows you to set the attributes for properties, methods, and events specified for a an item. Only available if you have one or more procedures defined. Dialog Box Options Name Lists the properties, methods, and events defined. The property, method, or event in the Code window in which the cursor is currently positioned appears selected. Description Displays the description of the property, method, or event that you want to show up in the Object Browser. Project Help File Displays the path to the help file for the project that is specified on the General tab of the Project Properties dialog box. This option is read only. Help Context ID Specifies the help context ID specified on the General tab of the Project Properties dialog box for the selected property or method. OK Applies the options to the selected property or method on the user control and closes the dialog box. Apply Applies the options to the selected property or method on the user control without closing the dialog box. Advanced Expands the dialog box to include the following options: Procedure ID Allows you to choose a standard member ID for the selected property, event, or method. The member ID is used to identify a property, method, or event as a standard type that control hosts may know about. A procedure whose ProcedureID is 0 acts as the default property or method for the control. It is also referred to as the Value property. Note When you set a property, method, or event as a standard type, it does not change the behavior of the control. It tells a control container that the property, method, or event will behave in the well-understood way but it does not create the behavior. It is up to you to make sure that the control behaves correctly. Caution If you make a public property or method of a class the default member for that class, you cannot edit the declaration for the member and change Public to Friend or Private without first removing the default attribute. If you inadvertently edit the declaration, make the member Public, remove the Default attribute, and then reset the declaration to Friend or Public. Use this Page in Property Browser Lists the Property Pages that are in the current project so you can select one to act as a builder when the property is chosen in the Property window. The property in the Property window is marked with a button and an ellipsis (.). When a user clicks the ellipsis, the Property Page specified is displayed. Valid only for properties. Default is None. Property Category Lists available categories to describe the selected property. You can select a standard category or type in one of your own. When you type in a category, the property browser automatically creates a new level for the property. Some property browsers such as Visual Basic allow you to categorize control properties. If the control host does not support property categorization, this setting will be ignored. Valid only for properties. Default is None. Attributes Allows you to set some standard behaviors of the selected property, method, or event. Hide this member - Determines whether the property, method, or event will appear to the end user of the control. If checked, it is hidden and cannot be seen in a property browser or the Object Browser. You can still write code to access it but it does not appear in the user interface. User Interface Default - Determines which property is highlighted in the property browser or which event is displayed in the Code window when you double-click the control. There can be only one User Interface default property and one User Interface default event. Not valid for methods. Don't show in Property Browser - Determines if a property, method, or event will be hidden in the property browser. It will continue to appear in the Object Browser and you can continue to write code to access it. This box is cleared when you choose Hide this member. Data Binding Determines whether a property can be bound or linked to a field in a database table. Property is data bound - Determines if the property is a data bound property. If this option is selected, the property supports data binding and appears in the DataBindings collection. The box is cleared by default. This property binds to DataField - Specifies whether the field to which the property is bound is specified in the DataField property. With this option, the end user does not have to use the Data Bindings collection and can use DataField. The box is cleared by default. Show in DataBindings collection at design time - Determines if the property will appear in the user interface as bindable atdesign time. If selected, the property appears in the Bindings dialog box. If cleared, the property does not appear in the user interface as a bindable property but you can continue to write code to access it. Property will call CanPropertyChange before changing - Tells the control container that the control will always call the CanPropertyChange method, and respect the return value, before changing a property value. The box is cleared by default. [page end] "gogza" wrote in message oups.com... How are we all today, I know that I can set the Value property as the default property for a class using: Attribute Value.VB_UserMemId = 0 (see http://www.cpearson.com/excel/DefaultProperty.htm, if you would like to know how to do this. Thanks Chip!) And i know that i can set up an enumrator, NewEnum, for a class using: Attribute NewEnum.VB_UserMemId = -4 But does anyone know where i can find documentation on these attribute statements. If this is possible in VBA then what else am I missing? Thanks, Gogza |
Attribute statements of VBA Classes
Wow, thanks Peter,
This is what i'm looking for. What would be cool is if someone with VB could apply some of these attributes to a class, export the .cls file and post it up here. Then I could see the syntax, to try out in VBA. No rush! This is just a matter of interest for me. Thanks again, Gogza |
Attribute statements of VBA Classes
Hi Gogza,
I haven't got round to looking again at these attributes in VB, however VBA does of course have a rather hidden dialog to add a description & help context id. In object browser, select project in the library & module name in classes (includes normal modules), function name in members, right click Properties. The description appears in Excel's function dialog if it's a UDF. Open the module in a text editor for the syntax. Regards, Peter T "gogza" wrote in message oups.com... Wow, thanks Peter, This is what i'm looking for. What would be cool is if someone with VB could apply some of these attributes to a class, export the .cls file and post it up here. Then I could see the syntax, to try out in VBA. No rush! This is just a matter of interest for me. Thanks again, Gogza |
All times are GMT +1. The time now is 12:09 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com