Public User Defined Types
I'm trying to use a public User Defined Type from within a class module. The UDT has been declared in a public module, the instance in a class module, like this:
VB Code:
'Module:
Public Type tText
Font As String
Format As String
End Type
'Class Module
Public Text as tText
This is not allowed, apparently. The compiler gives me this error:
Quote:
Originally Posted by VB Compiler
Constants, fixed-length strings, arrays, user-defined types and Declare statements not allowed as Public members of object modules.
Why can't UDT's be used publicly? :(
Re: Public User Defined Types
Don't use the UDT. Create a dummy class containing Public variables with the same names and definitions.
Re: Public User Defined Types
There's no point in using a UDT from within a Class Module. A Class Module will provide you with all of the capabilities of a UDT with additional OO functionality.
Re: Public User Defined Types
one slight thing...
Public Text as tText
Reserved word.. won't work because of that
try
Public sText As tText
Re: Public User Defined Types
Thanks for your replies. I've been using lots of class modules in my application and therefore I was trying UDT's; in this case I'd have to add five new class modules holding only a few variables each. It clutters up my structure... :(
@dannymking: good catch, hadn't noticed that. :)
Re: Public User Defined Types
Quote:
Originally Posted by dannymking
one slight thing...
Public Text as tText
Reserved word.. won't work because of that
Text is not a reserved word.