Class Module Properties

Depending on the type of project in which the class module (.cls) file is included, class modules support the following properties that control their precise behavior:

Instancing

Only available when a class is part of an ActiveX project, the instancing property defines how instances of the class are created. Its values are:

GlobalMultiUse

The class becomes global to the project in which it's defined; references are not necessary. For example, most VB language objects are global; as soon as you load the environment, they are available to be used. Use this property setting to create class modules containing enumerated constants for your object model.

70 Chapter 4 - Class Modules

MultiUse

The class has scope (i.e., it's visible) outside the project in which it's defined, and it can't be instantiated using the New keyword or the CreateObject function. Use this for top-level objects in a hierarchy or object model.

PublicNotCreateable

Although the class has scope (i.e., it's visible) outside of the project in which it's defined, it can't be instantiated from outside the project using the New keyword or the CreateObject function. Use this for child objects that can be created by accessing a function or property of a higher-level object.

Private

The class can't be "seen" outside the project in which it's defined. SingleUse

Every call by a client to create the object using either the New keyword or the CreateObject function creates a completely new instance of the object. Only available in ActiveX EXE projects.

GlobalSingleUse

As with the SingleUse property value, every call by a client to create the object using either the New keyword or the CreateObject function creates a completely new instance of the object. However, GlobalSingleUse allows methods and properties to be seen as part of VB. Only available in ActiveX EXE projects.

DataSourceBehavior

(VB6 only) This property, which isn't available when the class is part of an ActiveX EXE project, defines the ability of the class to serve as a data source for other objects. Values are:

vbNone

The class doesn't expose a bindable data interface.

vbDataSource

The class can act as a data source for other objects.

vbOLEDBProvider

The class can act as an OLE DB Simple Provider.

DataBindingBehavior

(VB6 only) This property controls the behavior of the class when it's bound to an external data source. Values are:

vbNone

The class can't be bound to external data sources. vbSimpleBound

The class can be to bound to a single data field in an external data source.

vbComplexBound

The class can be bound to a row of data in an external data source.

M

l

l

s

to

Creating ActiveX Components 71

MTSTransactionMode

(VB6 only) Only available when the class is part of an ActiveX DLL project; you should set this property whenever the class is registered within Microsoft Transaction Server. This property automatically sets the Transaction Support property for the object when it is registered in MTS, thereby giving the developer control over how the component is used by MTS. Values are:

NotAnMTSObject NoTransactions

Sets the Transaction Support property to "Does not support Transactions."

RequiresTransactions

Sets the Transaction Support property to "Requires a Transaction."

UsesTransactions

Sets the Transaction Support property to "Supports Transactions."

RequiresNewTransaction

Sets the Transaction Support property to "Requires a new Transaction."

Persistable

(VB6 only) Only available when a class is part of an ActiveX project, this property determines whether the class can be saved to disk. Values are:

NotPersistable

The class properties can't be saved.

Persistable

The class property values can be saved to a property bag.

Was this article helpful?

0 0

Responses

  • francis
    How to get value of global defined in activex from vba?
    8 years ago
  • priamus
    Can property bag be used in vb6 class module?
    2 years ago

Post a comment