From: Webbiz on
I'm a tad baffled as to what I'm doing wrong here.

I have a Sub in a Class Module...

Public Sub OpenDataBaseArray( arrData() as DATASTRUC)

I have the UDT defined in a .bas module as...

Public Type DATASTRUC
dDate As Date
fOpen As Single
fHigh As Single
fLow As Single
fClose As Single
lngVolume As Long
sSwingType As String
End Type


The UDT is declared PUBLIC
The SUB is declared PUBLIC

Why do I get this 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."


Thank you.

Webbiz

From: Ulrich Korndoerfer on
Hi,

Webbiz schrieb:
> I'm a tad baffled as to what I'm doing wrong here.
>
> I have a Sub in a Class Module...
>
> Public Sub OpenDataBaseArray( arrData() as DATASTRUC)
>
> I have the UDT defined in a .bas module as...
>
> Public Type DATASTRUC
> dDate As Date
> fOpen As Single
> fHigh As Single
> fLow As Single
> fClose As Single
> lngVolume As Long
> sSwingType As String
> End Type
>
>
> The UDT is declared PUBLIC
> The SUB is declared PUBLIC
>
> Why do I get this 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."

Read carefully:

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.

Your UDT is defined Public in a *module* (.bas). A module is not an
object module. Classes and Forms are object modules, bas-modules are not.

So your UDT at least had to be declared public in a Class or Form. But
this would not suffice. Also the whole object module (the Class or Form)
itself had to be public! However public object modules are only possible
in COM Servers (COM-Dll or OCX, or ActiveX Exe). In standard exes they
are always private.

Quintessence:

In standard exes you can not use public UDTs from modules as parameter
type in public methods of class modules.

But you can trick VB:

Friend Sub OpenDataBaseArray( arrData() as DATASTRUC)

will do.

--
Ulrich Korndoerfer

VB tips, helpers, solutions -> http://www.proSource.de/Downloads/
From: John Simpson on

"Webbiz" <nospam(a)noway.com> wrote in message
news:d5fnq5t4oh47rqg2ql0md4hbmhrq0c48iv(a)4ax.com...
> I'm a tad baffled as to what I'm doing wrong here.
>
> I have a Sub in a Class Module...
>
> Public Sub OpenDataBaseArray( arrData() as DATASTRUC)
>
> I have the UDT defined in a .bas module as...
>
> Public Type DATASTRUC
> dDate As Date
> fOpen As Single
> fHigh As Single
> fLow As Single
> fClose As Single
> lngVolume As Long
> sSwingType As String
> End Type
>
>
> The UDT is declared PUBLIC
> The SUB is declared PUBLIC
>
> Why do I get this 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."
>
>
> Thank you.
>
> Webbiz

Ditch the word 'Public'.

John


__________ Information from ESET Smart Security, version of virus signature database 4974 (20100325) __________

The message was checked by ESET Smart Security.

http://www.eset.com



From: Webbiz on
On Thu, 25 Mar 2010 21:07:50 +0100, Ulrich Korndoerfer
<ulrich_wants_nospam(a)prosource.de> wrote:


>
>Read carefully:
>
>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.

You know, I kept reading this over and over and over and it just
didn't click. My problem is that I did not realize that my .bas module
is not considered an 'object module'. Why I missed that I can't tell
you. Brain freeze?

>
>Your UDT is defined Public in a *module* (.bas). A module is not an
>object module. Classes and Forms are object modules, bas-modules are not.
>
>So your UDT at least had to be declared public in a Class or Form. But
>this would not suffice. Also the whole object module (the Class or Form)
>itself had to be public! However public object modules are only possible
>in COM Servers (COM-Dll or OCX, or ActiveX Exe). In standard exes they
>are always private.
>
>Quintessence:
>
>In standard exes you can not use public UDTs from modules as parameter
>type in public methods of class modules.
>
>But you can trick VB:
>
>Friend Sub OpenDataBaseArray( arrData() as DATASTRUC)
>
>will do.

Thank you!

Webbiz

From: Webbiz on
On Thu, 25 Mar 2010 16:09:13 -0400, "John Simpson"
<jasimp(a)earthlink.net> wrote:

>
>"Webbiz" <nospam(a)noway.com> wrote in message
>news:d5fnq5t4oh47rqg2ql0md4hbmhrq0c48iv(a)4ax.com...
>> I'm a tad baffled as to what I'm doing wrong here.
>>
>> I have a Sub in a Class Module...
>>
>> Public Sub OpenDataBaseArray( arrData() as DATASTRUC)
>>
>> I have the UDT defined in a .bas module as...
>>
>> Public Type DATASTRUC
>> dDate As Date
>> fOpen As Single
>> fHigh As Single
>> fLow As Single
>> fClose As Single
>> lngVolume As Long
>> sSwingType As String
>> End Type
>>
>>
>> The UDT is declared PUBLIC
>> The SUB is declared PUBLIC
>>
>> Why do I get this 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."
>>
>>
>> Thank you.
>>
>> Webbiz
>
>Ditch the word 'Public'.
>
>John


That didn't work.

However, using Friend instead of Public did.

:-)
Webbiz
 |  Next  |  Last
Pages: 1 2
Prev: DAO Question
Next: windows mobil develop