propiedad pro defecto (clases)

Josep
02 de Octubre del 2003
En un módulo de clase, como puedo especificar que una propiedad es la propiedad por defecto?
Me explico, con los objetos recordset si hacemos rs("campo1")=0 es lo mismo que hacer rs("campo1").value=0 es decir, que la propiedad value se supone por defecto...
Como puedo hacer lo mismo pero con una propiedad de mi clase??
Gracias.

sdemingo
02 de Octubre del 2003
Hola, espero que no se te de mal el inglés. Lo he encontrado en la MSDN.

You can mark the most commonly used public property or method of a class as the default method. This allows the user of a class to invoke the member without naming it.

To set a property or method as the default

On the Tools menu, click Procedure Attributes to open the Procedure Attributes dialog box.


Click Advanced to expand the Procedure Attributes dialog box.


In the Name box, select the property or method that is currently the default for the class. If the class does not currently have a default member, skip to step 5.
Note You can use the Object Browser to find out what the current default member of a class is. When you select the class in the Class list, you can scroll through the members in the Members list; the default member will be marked with a small blue circle beside its icon.

In the Procedure ID box, select None to remove the default status of the property or method.


In the Name box, select the property or method you want to be the new default.


In the Procedure ID box, select (Default), then click OK.
Important A class can have only one default member. If a property or method is already marked as the default, you must reset its procedure ID to None before making another property or method the default. No compile errors will occur if two members are marked as default, but there is no way to predict which one Visual Basic will pick as the default.

Fixing Defaults You Have Accidentally Made Private or Friend
The Procedure Attributes dialog box only allows you to select public properties and methods as the default for a class. If you make a public property or method the default for a class, and later change the declaration to Private or Friend, the property or method may continue to behave as if it were still declared Public.

To correct this problem, you must make the property or method Public again, because the Procedure Attributes dialog box will not show procedures declared Private and Friend. Once you have changed the declaration to Public, you can use the Procedure Attributes dialog to remove the Default attribute. You can then change the declaration back to Friend or Private.




Un saludo
sdemingo