Passing UDT to a subroutine 
Author Message
 Passing UDT to a subroutine

Receive the error "User-defined type and fixed-length strings not allowd as
the type of a Public memnber of an object module; Private object modules not
alowd as the type of a public member of a public object module"

when compiling the following code:

Module1

Option Explicit
Public Type featurekeys
    rb_prmry as integer
    rb_scndry as integer
    segment_name as string
    glnx as integer
    glny as integer
end type

Form1

Private fkeys(3000) as featurekeys
Public Sub FindMasterFiles(ByRef fkeys() as  featurekeys, feature_count as
integer)  'compile error occurrs on this line
end sub

Private Sub Command1_click()
fkeys(200).rb_prmry=200
fkeys(201).rb_prmry=201
call findmasterfiles(fkeys(),201)
end sub

What is the trick to passing UDT's to subroutines ???
Thanks



Sun, 04 Mar 2001 03:00:00 GMT  
 Passing UDT to a subroutine

Quote:

>Receive the error "User-defined type and fixed-length strings not allowd as
>the type of a Public memnber of an object module; Private object modules
not
>alowd as the type of a public member of a public object module"

>What is the trick to passing UDT's to subroutines ???

The real trick is to use VB6.

Other than that, the error message says it all. You can deal with this in
VB5 by declaring the sub or function as a Friend function rather than Public
function.

Frank Carr



Sun, 04 Mar 2001 03:00:00 GMT  
 Passing UDT to a subroutine

Quote:
>Receive the error "User-defined type and fixed-length strings not allowd as
>the type of a Public memnber of an object module; Private object modules not
>alowd as the type of a public member of a public object module"

>when compiling the following code:

>Module1

>Option Explicit
>Public Type featurekeys
>    rb_prmry as integer
>    rb_scndry as integer
>    segment_name as string
>    glnx as integer
>    glny as integer
>end type

>Form1

>Private fkeys(3000) as featurekeys
>Public Sub FindMasterFiles(ByRef fkeys() as  featurekeys, feature_count as
>integer)  'compile error occurrs on this line
>end sub

>Private Sub Command1_click()
>fkeys(200).rb_prmry=200
>fkeys(201).rb_prmry=201
>call findmasterfiles(fkeys(),201)
>end sub

>What is the trick to passing UDT's to subroutines ???

In VB5 the trick is to use an object instead of a UDT.  Create a class
for the information you have in the UDT.  You can easily pass objects
(and arrays of objects) around in VB5.

In VB6 you can pass a UDT to a subroutine, but using a class may still
be a better solution.

-- Roger

-------------------------------
No list server? Manage interactive mailing lists
on your PC with Arrow! http://www.jadebox.com/arrow/

***** Five-Star Rating from ZNet's Software Library!



Sun, 04 Mar 2001 03:00:00 GMT  
 Passing UDT to a subroutine
A Form module is basically a Class module, so the FindMasterFiles Sub of
your Form1 module is in fact a Public member of a Class Module. And so it
may not have an UDT as parameter, as the error message states :-(

Uli Foerster


Quote:
>Receive the error "User-defined type and fixed-length strings not allowd as
>the type of a Public memnber of an object module; Private object modules
not
>alowd as the type of a public member of a public object module"

>when compiling the following code:

>Module1

>Option Explicit
>Public Type featurekeys
>    rb_prmry as integer
>    rb_scndry as integer
>    segment_name as string
>    glnx as integer
>    glny as integer
>end type

>Form1

>Private fkeys(3000) as featurekeys
>Public Sub FindMasterFiles(ByRef fkeys() as  featurekeys, feature_count as
>integer)  'compile error occurrs on this line
>end sub

>Private Sub Command1_click()
>fkeys(200).rb_prmry=200
>fkeys(201).rb_prmry=201
>call findmasterfiles(fkeys(),201)
>end sub

>What is the trick to passing UDT's to subroutines ???
>Thanks



Sun, 04 Mar 2001 03:00:00 GMT  
 Passing UDT to a subroutine
Chris,

For some reason VB is not happy passing UDT's across the boundary between
modules.  If you define featurekeys as Private Type within Form1 everything
will work fine.

HTH

Peter

Quote:

>Receive the error "User-defined type and fixed-length strings not allowd as
>the type of a Public memnber of an object module; Private object modules
not
>alowd as the type of a public member of a public object module"

<snip>


Mon, 05 Mar 2001 03:00:00 GMT  
 Passing UDT to a subroutine
You can use lset to copy your udt to a string for transfer, it works like
this

Type Whatever
    aStr as string * 10
    AnInt as integer
end type

type Buffer
    aStr as string * 12
end type

if you lset a type whatever to a type buffer then you can assign astr to any
string and pass it wherever you want. The catch being you have to decode the
string on the other end by lset'ing it back into it's original type.

Note: The types have to be the same size, and I don't know if you can make
it work with arrays

Quote:

>Receive the error "User-defined type and fixed-length strings not allowd as
>the type of a Public memnber of an object module; Private object modules
not
>alowd as the type of a public member of a public object module"

>when compiling the following code:

>Module1

>Option Explicit
>Public Type featurekeys
>    rb_prmry as integer
>    rb_scndry as integer
>    segment_name as string
>    glnx as integer
>    glny as integer
>end type

>Form1

>Private fkeys(3000) as featurekeys
>Public Sub FindMasterFiles(ByRef fkeys() as  featurekeys, feature_count as
>integer)  'compile error occurrs on this line
>end sub

>Private Sub Command1_click()
>fkeys(200).rb_prmry=200
>fkeys(201).rb_prmry=201
>call findmasterfiles(fkeys(),201)
>end sub

>What is the trick to passing UDT's to subroutines ???
>Thanks



Mon, 12 Mar 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Passing UDT's to subroutines

2. Problems passing a fieldname as a parameter in a subroutine

3. Passing Variables to subroutines

4. Newbie: passing values through subroutines

5. passing parameter to a subroutine

6. Passing a pointer to a VB subroutine to a C DLL

7. passing arrays to subroutines in Excel Visual Basic

8. Passing an array to a subroutine

9. Passing arguments to a subroutine

10. Passing arguments to a subroutine

11. Pass a datacontrol to a subroutine?

12. Passing Arrays to Subroutines

 

 
Powered by phpBB® Forum Software