Results 1 to 3 of 3

Thread: passing structures (user defined types) as parameters of function

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Location
    Srbija
    Posts
    2

    passing structures (user defined types) as parameters of function

    In module I defined public type
    Then in class module I use that type as argument of function
    An at last when I try to call that function from form module passing variable of defined type.

    When I try to run that program I get this compiler error:
    "Only public user defined types defined in public object can be used as parameters or return types for public procedures of class modules or as fields of public defined types"

    Where is problem?
    Thanx in advance for any help.

  2. #2
    Frenzied Member jjortiz's Avatar
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    1,768
    Cannot define a KWID_tkPUBLIC user-defined type within a private object module


    A user-defined type that appears within an object module can't be Public. This error has the following cause and solution:

    You tried to define a Public user-defined type in an object module.
    Move the user-defined type definition to a standard module, and then declare variables of the type in the object module or other modules, as appropriate. If you only want the type to be available in the module in which it appears, you can place its Type...End Type definition in the object module and precede its definition with the Private keyword.

  3. #3
    Fanatic Member Kaverin's Avatar
    Join Date
    Oct 2000
    Posts
    930
    If you don't want to solve it that way, you can make a class that privately defines the UDT, and exposes the members of the UDT through public properties. Then make your function accept an instance of that class. You'd be accessing it the exact same way, except you'd just create it a little differently to start out since it's a class.
    I'm baaaack...
    VB5 Professional Edition, VC++ 6
    Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se

    I feel special because I finally figured out how to loop midis: Post link
    I'm a fanatic too

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width