473,589 Members | 2,652 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

type in a class problem

Hi I´m trying to encapsulate a type in a class but I´m getting this
error message (Compiler error), could you please explain what I´m doing
wrong.

/Olle
Compile error:
Only public user defined types defined in public object modules can be
used as parameters or return types för public procedures of class
modules or as fiedls of public user defined types

---

in module1.bas
public type MyTestType
name as String
end type

---

in MyTestTypeWrapp er.cls

Private mvarm_block As Module1.MyTestT ype 'local copy

Public Property Set m_block(ByVal vData As Module1.MyTestT ype)
Set mvarm_block = vData
End Property

Public Property Get m_block() As Module1.MyTestT ype
Set m_block = mvarm_block
End Property

---

Jul 17 '05 #1
1 5669
The confusion arises because public, as used in the error message, is not just
whether the type was declared public, but whether the module it is in is also
public. A .bas module is not public. In this sense, public means, "would it be
visible if you built an ActiveX.dll and then used it in another program?"
Classes yes; modules no. In a regular app, there are no such public modules.

So what to do? If you are programming with a single app, you could make your
class members Friend instead of Public. Since a type is not an object, you will
also need to change the Set property to a Let property. You will also need to
change the ByVal to ByRef.

A better plan: make the type private inside the class module, declare a private
instance, and expose it one element at a time. In your case, a Name property
that lets and gets the value of mvarm_block.nam e, for instance.

"Olle Lundin" <ol************ ***@telia.com> wrote in message
news:gh******** ***********@new sb.telia.net...
Hi I´m trying to encapsulate a type in a class but I´m getting this
error message (Compiler error), could you please explain what I´m doing
wrong.

/Olle
Compile error:
Only public user defined types defined in public object modules can be
used as parameters or return types för public procedures of class
modules or as fiedls of public user defined types

---

in module1.bas
public type MyTestType
name as String
end type

---

in MyTestTypeWrapp er.cls

Private mvarm_block As Module1.MyTestT ype 'local copy

Public Property Set m_block(ByVal vData As Module1.MyTestT ype)
Set mvarm_block = vData
End Property

Public Property Get m_block() As Module1.MyTestT ype
Set m_block = mvarm_block
End Property

---

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2521
by: Faheem Mitha | last post by:
Hi, I'm not sure what would be more appropriate, so I'm ccing it to both alt.comp.lang.learn.c-c++ and comp.lang.python, with followup to alt.comp.lang.learn.c-c++. While working with a random number generator in the context of a mixed Python/C++ programming problem. I encountered a vexing type conversion problem.
0
1637
by: Rajesh Kumar | last post by:
Hi Gregory Thanks for your answer. I did not see any attached file so I copied your text into a text file and named it compiler.bat Checked the wrapped lines and runned the file. It said Dataset, Datareader and some other things are not defined. So I entered the : Imports Microsoft.ApplicationBlocks.Data Imports system Imports system.data Imports System.Data.SqlClient
0
3360
by: Rajesh Madhra | last post by:
Hi Gregory Thanks for your answer. I did not see any attached file so I copied your text into a text file and named it compiler.bat Checked the wrapped lines and runned the file. It said Dataset, Datareader and some other things are not defined. So I entered the : Imports Microsoft.ApplicationBlocks.Data Imports system Imports system.data Imports System.Data.SqlClient
1
1019
by: sympatico | last post by:
i'm stuck with a class problem, i want to create a class that, say for example gets the system time, and can be displayed in label or textbox but can be accessed many times.... ok i'll start with a pseudo example. VB.NET pseudo code.... public function test(variable)
5
5550
by: Macca | last post by:
Hi, My application receives data from multiple sources transferred over ethernet. This data is broken into packets of bytes before being transmitted over the network. My application has to take the data and arrange into a user defined type/class. e.g one message from source 1 may be 10-15KB. This is broken down into
5
4109
by: Martin Jørgensen | last post by:
Hi, Consider this code: --- beginning of code --- #include <iostream> using namespace std; class Child{ public:
7
1945
by: Michael | last post by:
Hi, I could understand the difference between class and object. However, I could find out a good definiton of type. how to understand the relaitonship between type, class, and object? Thanks! Michael
9
5494
by: silversurfer2025 | last post by:
Hello everyone, I am currently having problems with a C++ abstract class. I have a class FrameWork.h which defines some methods (of which some are abstract, i.e. virtual void method() = 0). In FrameWork.cpp I define some of the methods while I naturally leave the abstract methods undefined. Now I wrote a class FrameWork_GUI.h which inherits from the abstract FrameWork class and implements the missing (so far abstract) methods....
1
2000
by: studio60podcast | last post by:
I have a solution I inherited from previous developers that includes web projects whose output type = class library. I need to add web forms and web user controls, but when I try to add them, it wants to add the .cs file, not the aspx or ascx files. How do I do this? Thanks! Jason
2
1359
by: THEAF | last post by:
i'm using this for my list box: Private Sub lstStock_Click() ' rsMyRS.FindFirst "Stockcode=" & Str(lstStock.ItemData(lstStock.ListIndex)) txtCode.Text = rsMyRS!Stockcode optVegi.Value = rsMyRS!Vegibox And this for my Form load:
0
7931
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8233
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8360
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8224
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6637
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5731
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5399
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3889
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1198
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.