Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Passing UDT to CLASS

1 view
Skip to first unread message

Webbiz

unread,
Sep 6, 2009, 12:59:13 AM9/6/09
to
I'm trying to setup my Class Module so that it can accept data from an
array of UDT DATA_ARRAY.

In a MODULE (.bas), I created this UDT as:

Public Type DATA_ARRAY
dDate As Date
Open As Single
High As Single
Low As Single
Close As Single
Vol As Long
OI As Long
End Type

In the General Declarations of cPanels (CLASS MODULE), I defined:

Private m_DataArray() As DATA_ARRAY


And in cPanels included:

Property Let AssignData(DataArray() As DATA_ARRAY)

m_DataArray = DataArray

End Property

Compile Error:
Only public user defined types defined in public object modules can be
used as parameters or return types for public procedures of class
modules or as fields of public user defined types.

"Only public user defined types..." : Well, my UDT is public.

"...defined in public object modules..." :

I'm not sure if a .bas MODULE is considered an 'object' module, but I
also tried to put my UDT in the cPanels class as well and that didn't
work either. So I'm not sure what the problem is here.

But since "class modules" is mentioned also in this error message, I
have to assume it is not the same as "object modules", and the other
other modules I see here other than "class modules" via the IDE are
these .bas Modules.

So this error does not make sense to me.

Help?

Webbiz


Webbiz

unread,
Sep 6, 2009, 1:07:49 AM9/6/09
to
Okay, this is different.

I put "Friend" in front of "Property Let" and it compiled okay.

So many stipulations. ;-b

Webbiz


On Sat, 05 Sep 2009 23:59:13 -0500, Webbiz <nos...@forme.thanks.com>
wrote:

Ralph

unread,
Sep 6, 2009, 1:47:11 PM9/6/09
to

"Webbiz" <nos...@forme.thanks.com> wrote in message
news:jqg6a51u59pptoaha...@4ax.com...

> Okay, this is different.
>
> I put "Friend" in front of "Property Let" and it compiled okay.
>
> So many stipulations. ;-b
>

Another 'work-around' is to define and use a Type Library.

Here is a great tutorial for using typelibs:
http://www.devx.com/vb2themax/Article/19830/1763/page/1

If you are not using Pro/Ent editions you can get a TypeLib compiler as part
of McKinney's WinAPI typelib download. This package is useful as you can use
and abuse his IDLs as 'seeds' and examples for creating your own.
http://vb.mvps.org/hardcore/html/sourcecode.htm
(download the WinTlbU.zip)

-ralph


Bob Riemersma

unread,
Sep 6, 2009, 4:36:26 PM9/6/09
to
No, your UDT is not "public" in the sense the word is used here. The error
message refers to "public" as in "published" i.e. having it defined in a
registered typelib.

This isn't the same as simply using the "Public" keyword in your program...
though things decorated that way do get published when you create something
that can be registered (ActiveX EXE, DLL, OCX).

Think of it as "public" in a broader sense: not just within your program but
within the whole computer.

"Webbiz" <nos...@forme.thanks.com> wrote in message

news:eqf6a59gttcko5a4a...@4ax.com...


> "Only public user defined types..." : Well, my UDT is public.
>
> "...defined in public object modules..." :
>
> I'm not sure if a .bas MODULE is considered an 'object' module, but I
> also tried to put my UDT in the cPanels class as well and that didn't
> work either. So I'm not sure what the problem is here.

> Webbiz

Nobody

unread,
Sep 6, 2009, 5:17:21 PM9/6/09
to
Here is a break down of the visibility of Private/Friend/Public:

- Private does not allow the method to be seen in other modules in the
project nor outside the project.
- Friend allows the method to be seen in all modules in the project, but not
outside the project.
- Public allows the method to be seen in all modules in the project and
outside the project(Except standard EXE).

Sometimes when you have a standard EXE project, the compiler objects to
using "Public" in certain situations(in class modules), so in these cases
use "Friend" instead.

Webbiz

unread,
Sep 6, 2009, 6:31:13 PM9/6/09
to
Thanks for the tip Ralph. I'll check out what these Typelibs are
about.

Yes, I'm using Professional version.

:-)

Webbiz


On Sun, 6 Sep 2009 12:47:11 -0500, "Ralph" <nt_cons...@yahoo.com>
wrote:

Bee

unread,
Sep 6, 2009, 11:07:01 PM9/6/09
to
Note: you cannot pass the UDT to a Friend that is a late bound function.
Using an object always works (I think).
Can someone explain the inner working of this NOT working?
Seems like it could/should.

Ralph

unread,
Sep 6, 2009, 11:47:19 PM9/6/09
to
Bee wrote:
> Note: you cannot pass the UDT to a Friend that is a late bound
> function. Using an object always works (I think).
> Can someone explain the inner working of this NOT working?
> Seems like it could/should.
>

You need to be a little clearer on the scenario you are describing. Friend
methods and properties are never part of a public interface and thus could
never be accessed in a late-bound component, with or without UDTs.

So what am I missing? <grin>

-ralph


0 new messages