Results 1 to 5 of 5

Thread: [RESOLVED] How to access Module items in a DLL.

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2013
    Posts
    48

    Resolved [RESOLVED] How to access Module items in a DLL.

    I'm having to convert an OLD VB6 application to VB.NET.

    There are bits of the VB6 stuff that will not convert and what I'm trying to do is create a DLL that can do those bits and return a Type value.

    I've finally got the thing compiling, but I'm now having a problem as to how to get the values back to my VB.NET calling routine.

    VB6 does NOT allow User Defined Types to be returned (Public) from a Class, you can only do this from a Module, so I've coded the functions in the Module.

    Now, how do I go about getting access to those functions from the calling program.

    'VB.NET:
    Code:
    Imports DllApplication
    Dim oDll as new clsDllClass(value1, value2)
    This where I get stuck. I can access anything as normal using the "oDll.Sub/Function/Property/Public" but the Public stuff in the Module is just not visible.

    Does anyone know how I can go about solving this problem as I cannot put anything that returns a UDT to a Structure variable in the Class.

    Help!

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: How to access Module items in a DLL.

    VB6 does NOT allow User Defined Types to be returned (Public) from a Class, you can only do this from a Module, so I've coded the functions in the Module.
    Not necessarily true. A VB6 DLL/OCX can return UDTs, but the UDTs must be declared public in a global class.

    1) Create a new class in vb6 dll/ocs project and change it's "Instancing" property to GlobalMultiUse
    2) Add UDTs to that class and declare them public
    3) Any project referencing those (VB6 at least) can now create those UDTs and pass them around

    I use this method for OCXs when I want the user to be able to pass/receive my custom UDTs
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2013
    Posts
    48

    Re: How to access Module items in a DLL.

    I've done as you suggested, but I'm still getting the error:

    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.

    I get this error every time I try to put ANYTHING that allows public access to the UDTs, functions, subs(byref) properties etc.

    If I try to return the UDT as a ByRef variant then I get the error:

    Only user-defined types defined in public object modules can be coerced to or from a variant or passed to late-bound functions.

    All the UDTs are defined in a module as Public. The Class instances is 6.

    How did you get around this problem? How can I make a "module" a "public object module"
    Last edited by JA12; Dec 16th, 2014 at 05:13 AM.

  4. #4
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,904

    Re: How to access Module items in a DLL.

    The UDTs should be declared in the DLL main class.

  5. #5

    Thread Starter
    Member
    Join Date
    Jul 2013
    Posts
    48

    Re: How to access Module items in a DLL.

    OK, thanks for the help. All the errors I was getting suggested otherwise!

    I've got it (sort of) working now, at least it's compiling...

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