User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion

Reply
Thread Tools Display Modes
Unread 12 May 2005, 10:56   #1
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
boohoo... VB is being nasty again - returning user defined types from a class module

I made this neat manager (in a class module) that manages some complex datastructures.
I want to display some information of these datastructures in a form.
So I thought it'd be nice to make a function that returns one of these structures.

Code:
' in the class module
public function getStructure() as myUDT

end function
Code:
' in a module
public type myUDT

en type
Now, my good intentions were quickly shattered by VB (I swear to god, the guy who came up with this nonsense should be shot in the face... with a torpedo). It says:
Quote:
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.
In my eyes I did exactly as described in the message. My UDT is public, in a public module, and it's used in a public procedure of a class module.

Moving the UDT to the class itself doesn't work either as it cannot be public (so not accessible from the form), nor can I make it public inside the class as that isn't allowed either.
I also tried returning an "Object", but that gives me an "incompatible type" error.

So, how am I going to do this? Google came up with having a "MultiUse Class" and accessing the UDT as "myClass.myUDT", but I can't find anything about making such a "MultiUse Class".
__________________
"Yay"
Structural Integrity is offline   Reply With Quote
Unread 12 May 2005, 11:09   #2
meglamaniac
Born Sinful
 
meglamaniac's Avatar
 
Join Date: Nov 2000
Location: Loughborough, UK
Posts: 4,059
meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.meglamaniac has ascended to a higher existance and no longer needs rep points to prove the size of his e-penis.
Re: boohoo... VB is being nasty again - returning user defined types from a class module

If this was C++ i'd tell you to return a pointer to the struct.
As it isn't I'm a bit stumped. It would indeed seem you've done everything the error suggests you do.
Hmm.
__________________
Worth dying for. Worth killing for. Worth going to hell for. Amen.
meglamaniac is offline   Reply With Quote
Unread 12 May 2005, 11:45   #3
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
Re: boohoo... VB is being nasty again - returning user defined types from a class mod

Quote:
Originally Posted by meglamaniac
If this was C++ i'd tell you to return a pointer to the struct.
As it isn't I'm a bit stumped. It would indeed seem you've done everything the error suggests you do.
Hmm.
If this was C++, yes. Even with C this would have been possible.
Alternatively, I could write a function to retrieve every possible member of all UDT's. Or I could just not use a class module but a normal module, but I think that's unpretty, especially if I decide I want to use multiple instances (that is not the case at the moment, I only plan to have one instance).

I've considered moving everything to a DLL and writing that in C/C++, but I need a database connection to fill the structure in the first place, which is much easier to accomplish in VB.

I'd love to find a way to make this work.
__________________
"Yay"
Structural Integrity is offline   Reply With Quote
Unread 12 May 2005, 18:05   #4
Caesar2
Commander
 
Caesar2's Avatar
 
Join Date: Sep 2001
Location: Netherlands
Posts: 146
Caesar2 is just really niceCaesar2 is just really niceCaesar2 is just really niceCaesar2 is just really nice
Re: boohoo... VB is being nasty again - returning user defined types from a class module

heh you asked this before
__________________
Quote:
Originally posted by Cochese
Cathaar are not overpowered.

You were just "bashed", live with it.
Caesar2 is offline   Reply With Quote
Unread 12 May 2005, 19:37   #5
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
Re: boohoo... VB is being nasty again - returning user defined types from a class module

I deserve a kick in the arse.
__________________
"Yay"
Structural Integrity is offline   Reply With Quote
Unread 13 May 2005, 13:09   #6
queball
Ball
 
queball's Avatar
 
Join Date: Oct 2001
Posts: 4,410
queball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so little
Re: boohoo... VB is being nasty again - returning user defined types from a class module

I'll polish my boots.
queball is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Forum Jump


All times are GMT +1. The time now is 11:45.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018