Solved

Passing user defined types between modules

Posted on 1998-07-24
2
285 Views
Last Modified: 2010-05-03
Is it possible to pass user defined types between modules? I am receiving the following error message if I pass an instance of my type to a public sub: "User-defined types and fixed-length strings not allowed as the type of a Public member of an object module; Private object modules not allowed as the type of a public member of a public object modules", passing to a private sub in the same module is OK.

0
Comment
Question by:mark_s
2 Comments
 
LVL 1

Accepted Solution

by:
gissing earned 50 total points
ID: 1466584
If you want to pass a UDT between two modules, the UDT has to be declared as public, so that both modules can see it.
0
 
LVL 6

Expert Comment

by:anthonyc
ID: 1466585
Classes can not have methods that have parameters using UDTs... if they are exposed (public).   To combat this, you can do one of 2 things:

1)  Build another class, which just has variables for your type, and pass that

2)  Build a collection to pass back and forth, using the KEY as the name of each variable


Mark's answer is wrong in this case..  He's correct for bas modules.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question