|
-
Oct 17th, 2001, 07:06 AM
#1
Thread Starter
New Member
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.
-
Oct 18th, 2001, 09:21 AM
#2
Frenzied Member
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.
-
Oct 19th, 2001, 04:21 AM
#3
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|