473,770 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Structures, Classes, Enums, Oh My!

I have a situation that I want to work but don't know the proper way to
handle it.

I want to create a User Defined "Type" (structure, class or
enumeration). I'm not sure what it should be or where it should
reside. I'll use Enum for this example.

Currently in a Public Module:
----------------------------
Public Enum MyUserDefinedTy pe
A = 1
B = 2
C = 3
End Enum
I have a class with a public method.

Currently in a MyTestClass.vb class:
-----------------------------------

Public Class MyTestClass

Public Sub MyObjectsSub1(B yVal P1 As MyUserDefinedTy pe)
... blah, blah, blah
End Sub

End Class

The syntax error I get in the class for using MyUserDefinedTy pe as the
type for P1 is:

'P1' cannot expose a Friend type outside of the public class
'MyTestClass'.

I want my class to be able to use the MyUserDefinedTy pe, but I want my
other code (forms, other modules, etc.) to also be able to use
MyUserDefinedTy pe. Anyone have any thoughts on this?

Any help would be greatly appreciated.

Nov 21 '05 #1
2 1409
Paul,
| Currently in a Public Module:
| Public Enum MyUserDefinedTy pe
Ah! There's the Rub!!!

I suspect you defined your module as "Module SomeModule" instead of "Public
Module SomeModule" as the default visibilty on modules is Friend.

As you noted Enums are Types just like Modules & Classes. Seeing as Enums
are Types, I normally define them at file level instead of inside a Module
or Class.

When I'm defining an Enum, I normally add a new Class to my project to give
me the file, then I simply delete the Class definition & add the Enum
definition.

Hope this helps
Jay

"Paul" <pw****@hotmail .com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
|I have a situation that I want to work but don't know the proper way to
| handle it.
|
| I want to create a User Defined "Type" (structure, class or
| enumeration). I'm not sure what it should be or where it should
| reside. I'll use Enum for this example.
|
| Currently in a Public Module:
| ----------------------------
| Public Enum MyUserDefinedTy pe
| A = 1
| B = 2
| C = 3
| End Enum
|
|
| I have a class with a public method.
|
| Currently in a MyTestClass.vb class:
| -----------------------------------
|
| Public Class MyTestClass
|
| Public Sub MyObjectsSub1(B yVal P1 As MyUserDefinedTy pe)
| ... blah, blah, blah
| End Sub
|
| End Class
|
| The syntax error I get in the class for using MyUserDefinedTy pe as the
| type for P1 is:
|
| 'P1' cannot expose a Friend type outside of the public class
| 'MyTestClass'.
|
| I want my class to be able to use the MyUserDefinedTy pe, but I want my
| other code (forms, other modules, etc.) to also be able to use
| MyUserDefinedTy pe. Anyone have any thoughts on this?
|
| Any help would be greatly appreciated.
|
Nov 21 '05 #2
Thanks Jay! That worked.

Nov 21 '05 #3

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

Similar topics

4
2276
by: David Rasmussen | last post by:
The problem comes up in all sorts of contexts. But here is an example: We want to model the basics of chess, maybe for making a chess program, or maybe just to make an interactive board or ... We have to have the notions of colors, squares and pieces represented. Ideally, we want to be able to do things like initializing the board: void initial() {
6
4488
by: Ken Allen | last post by:
OK, I admit that I have been programming since before C++ was invented, and I have developed more than my share of assembly language systems, and even contributed to operating system and compiler systems over the years. I have developed code in more than 30 distinct programming languages for a wide cariety of industries. But this issue of structures in C# is beginning to annoy me. I should also make it clear that I am not a big supporter...
0
1075
by: Edward Diener | last post by:
Why is there a prohibition of instantiating __value type enums and classes within __nogc classes ? After all __value types are not managed by the GC and built-in __value types, such as 'int', are allowed inside __nogc classes as the type of fields. Yet when I try to instantiate a __value enum or __value class inside of a __nogc class, the compiler gives me error C3265. I am looking for the reason for this restriction.
14
15090
by: pmclinn | last post by:
I've noticed that many programmers use classes to store data about such things like: Class Customers .....Phone ....ID ....Address End Class....
2
2410
by: thomasfarrow | last post by:
At work, our development team has a development standards document that insists Structures should never be used. I'm looking to change this standard but need a suitable argument in order to make the change. I know that Structures are value types, sit on the stack, and are generally more efficient to manipulate than reference types (i.e. Classes). Structures cannot use inheritance, the finalize method or default constructors. Can anyone...
1
1399
by: Ripal | last post by:
Hi I am facing problem descripbed as follows: I have 4 enums, 10 structures and methods exposed via web method It was working fine till the 7 structures after adding more 3 structures I am not able to create the instance of the 2 structures out of 10.
7
4353
by: Adrian Hawryluk | last post by:
Can one define a partial class (first part containing constants like enums) and then define the rest of the class elsewhere? I ask this because I've had in the past needed to defined two classes (call them A and B), each dependent upon the other. Class A requires the enum type defined in Class B. An example follows: <header file="A.h"> #if !defined A_H # define A_H
6
3534
by: titan nyquist | last post by:
Can you make volatile structures in C#? I have a static class, to have "global" variables. This allows the whole program to see them. I make them "volatile" to avoid multi- threading accessing issues. That works. THE PROBLEM: In that static class, I want to combine some variables inside a structure, and then make a variable of that structure type,
6
4033
by: Miguel Guedes | last post by:
Hello, I recently read an interview with Bjarne Stroustrup in which he says that pure abstract classes should *not* contain any data. However, I have found that at times situations are when it would be useful to have /some/ data defined in such an abstract class for reasons of forming a common block of data existing in or used by all descendant classes (see example below.) In such a case where a common block of data *always* exists,...
0
9618
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
10260
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
10101
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...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9906
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
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
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.