Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is a "Public Object Module"

Status
Not open for further replies.

Leviathan07

Programmer
Jul 14, 2000
11
CA
Here is the problem:

I tried creating a Public Type in a module and then pass it into a TagVariant (Variant Data Type) on another control, however, I got an error that says I cannot do this unless it is part of a Public Object Module. So what is a Public Object Module, as I could find no documentation on it.

To replicate:

Create a module and place in it
Public Type Test
A as string
B as string
end type

then on a form_load do this:
dim varA as variant
dim udtA as test

udta.a = "1"
udta.b = "2"
vara = udta 'This line generates the compile error
 
Hi Leviathan07,

Take a look at: thread222-171523

In particular the links to Microsoft's site.

Regards,

Codefish
 
If you put your UDT in a ActiveX DLL and set the instancing to multiuse that should do it.
 
Modules are usually private, that is they have scope only to their project. It's the classes of a component become available to other projects as objects.

In your case, all you really need is a class. You'll end up having to use SET, but it's not a big price. After all, a class is just a more modern version of a type.

Create a class module, named Class1, and add the following 2 lines
[tt]Public a As String
Public b As String[/tt]

Change your form load code to[tt]
dim varA as variant
dim udtA as new Class1 ' Substitute your class's name

udta.a = "1"
udta.b = "2"
set vara = udta 'This line no longer generates the compile error
debug.print vara.a, vara.b
[/tt]

Remember that the variables have scope only to the function. If you want the object to persist you'll need to define it at an outer layer.

Wil Mead
wmead@optonline.net

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top