Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

jbarczak

Visual Basic 6 -- passing UDTs

This topic is 5816 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, say I''ve got a standard exe project with a UDT defined in a module, something like: public type foo_type bar as integer lish as integer end type Then, in a class or form module, I try and do this: public sub MySub(x as foo_type) ..... end sub This produces a compile error, because, according to MS "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" Two questions: 1. Can anybody think of a rational reason why they did this? It seems like an arbitrary restriction, at least in Standard EXE projects. I poked around in MSDN but didn''t find an explanation. 2. Is there any way to work around it without turning all the UDTs into class objects? I thought about passing it in as a Variant, but I''m not sure I like that idea Thanks. JB

Share this post


Link to post
Share on other sites
Advertisement
It has to do with the fact that VB uses COM for everything (classes, functions, etc.). There seems to be a slight incompatibility with COM and VB''s UDTs.

(It is no longer an issue in VB.NET, but that is due to the way the .NET framework handles Structures.)

It has been a while since I used VB6, but can you define your UDT in your class?

--TheMuuj

Share this post


Link to post
Share on other sites

OH NEVERMIND!

I have a workaround.

Since this is a standard EXE, "Public" is pretty meaningless. Use "friend" for everything instead, and you won''t have a problem.

--TheMuuj

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!