473,383 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Need help with scope

I want to create a public enum that can be used throughout a project. I
created an enum like this in a module:

Public Enum ParentType
Project = 0
Stage = 1
VIP = 2
Func = 3
Equipment = 4
Idea = 5
Tech = 6
End Enum

I have been able to declare private variables as ParentType and pass them as
parameters from method to method OK. Now I need to create a public property
in a class as ParentType like this:
Private miCurrentParentType As ParentType

Public Property CurrentParentType() As ParentType
Get
Return miCurrentParentType
End Get
Set(ByVal Value As ParentType)
miCurrentParentType = Value
End Set
End Property

I get a blue squiggly under ParentType in the line:
Public Property CurrentParentType() As ParentType

and the compile error is:
'CurrentParentType' cannot expose a Friend type outside of the Public class
'Tech_UIL'.

I often have similar problems where I have a public enum or structure and
want to declare variables as these types and pass or reference them around
the application.

Is there a way to do this? Also, eventually, the project will be broken
into smaller projects such as a business tier and data access tier and I
will want to have these types referenced as described above throughout the
entire solution across projects.

any recomendations?

Thanks.


--
mo*******@nospam.com
Nov 21 '05 #1
7 1413
"moondaddy" <mo*******@nospam.com> schrieb:
I want to create a public enum that can be used throughout a project. I
created an enum like this in a module:

Public Enum ParentType
Project = 0
Stage = 1
VIP = 2
Func = 3
Equipment = 4
Idea = 5
Tech = 6
End Enum

I have been able to declare private variables as ParentType and pass them
as parameters from method to method OK. Now I need to create a public
property in a class as ParentType like this:
Private miCurrentParentType As ParentType

Public Property CurrentParentType() As ParentType
Get
Return miCurrentParentType
End Get
Set(ByVal Value As ParentType)
miCurrentParentType = Value
End Set
End Property

I get a blue squiggly under ParentType in the line:
Public Property CurrentParentType() As ParentType

and the compile error is:
'CurrentParentType' cannot expose a Friend type outside of the Public
class 'Tech_UIL'.


Place the 'Public Enum...End Enum' /outside/ any module, for example, in a
separate file.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
There is something wrong in your post, because if the ParentType enum is
declared as Public as you state, it works fine. Only if you change its scope
to Friend you get that error.

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
"moondaddy" <mo*******@nospam.com> escribió en el mensaje
news:uH**************@TK2MSFTNGP14.phx.gbl...
I want to create a public enum that can be used throughout a project. I
created an enum like this in a module:

Public Enum ParentType
Project = 0
Stage = 1
VIP = 2
Func = 3
Equipment = 4
Idea = 5
Tech = 6
End Enum

I have been able to declare private variables as ParentType and pass them
as parameters from method to method OK. Now I need to create a public
property in a class as ParentType like this:
Private miCurrentParentType As ParentType

Public Property CurrentParentType() As ParentType
Get
Return miCurrentParentType
End Get
Set(ByVal Value As ParentType)
miCurrentParentType = Value
End Set
End Property

I get a blue squiggly under ParentType in the line:
Public Property CurrentParentType() As ParentType

and the compile error is:
'CurrentParentType' cannot expose a Friend type outside of the Public
class 'Tech_UIL'.

I often have similar problems where I have a public enum or structure and
want to declare variables as these types and pass or reference them around
the application.

Is there a way to do this? Also, eventually, the project will be broken
into smaller projects such as a business tier and data access tier and I
will want to have these types referenced as described above throughout the
entire solution across projects.

any recomendations?

Thanks.


--
mo*******@nospam.com

Nov 21 '05 #3
Carlos (& moondaddy),
I want to create a public enum that can be used throughout a project. I
created an enum like this in a module: The default for Modules are Friend, which (more then likely) means that
moondaddy has something like:

Module SomeModule
Public Enum ParentType ... End Enum
End Module

Which causes the error. As Herfried suggests, do not put Enums in a Module,
simply put them in a source file.
Public Enum ParentType ... End Enum

Friend Module SomeModule

End Module

moondaddy,
Structures, Enums & Delegates can all be put in their own source files, they
do not need to be contained directly within Module statements.

Hope this helps
Jay

"Carlos J. Quintero [.NET MVP]" <ca*****@NOSPAMsogecable.com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl... There is something wrong in your post, because if the ParentType enum is
declared as Public as you state, it works fine. Only if you change its
scope to Friend you get that error.

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
"moondaddy" <mo*******@nospam.com> escribió en el mensaje
news:uH**************@TK2MSFTNGP14.phx.gbl...
I want to create a public enum that can be used throughout a project. I
created an enum like this in a module:

Public Enum ParentType
Project = 0
Stage = 1
VIP = 2
Func = 3
Equipment = 4
Idea = 5
Tech = 6
End Enum

I have been able to declare private variables as ParentType and pass them
as parameters from method to method OK. Now I need to create a public
property in a class as ParentType like this:
Private miCurrentParentType As ParentType

Public Property CurrentParentType() As ParentType
Get
Return miCurrentParentType
End Get
Set(ByVal Value As ParentType)
miCurrentParentType = Value
End Set
End Property

I get a blue squiggly under ParentType in the line:
Public Property CurrentParentType() As ParentType

and the compile error is:
'CurrentParentType' cannot expose a Friend type outside of the Public
class 'Tech_UIL'.

I often have similar problems where I have a public enum or structure and
want to declare variables as these types and pass or reference them
around the application.

Is there a way to do this? Also, eventually, the project will be broken
into smaller projects such as a business tier and data access tier and I
will want to have these types referenced as described above throughout
the entire solution across projects.

any recomendations?

Thanks.


--
mo*******@nospam.com


Nov 21 '05 #4
Can't you put the Enums before your Module Statement like:

PUblic Enum myEnum
first
End Enum

PUblic Module myModule
.....
End Module

"moondaddy" wrote:
I want to create a public enum that can be used throughout a project. I
created an enum like this in a module:

Public Enum ParentType
Project = 0
Stage = 1
VIP = 2
Func = 3
Equipment = 4
Idea = 5
Tech = 6
End Enum

I have been able to declare private variables as ParentType and pass them as
parameters from method to method OK. Now I need to create a public property
in a class as ParentType like this:
Private miCurrentParentType As ParentType

Public Property CurrentParentType() As ParentType
Get
Return miCurrentParentType
End Get
Set(ByVal Value As ParentType)
miCurrentParentType = Value
End Set
End Property

I get a blue squiggly under ParentType in the line:
Public Property CurrentParentType() As ParentType

and the compile error is:
'CurrentParentType' cannot expose a Friend type outside of the Public class
'Tech_UIL'.

I often have similar problems where I have a public enum or structure and
want to declare variables as these types and pass or reference them around
the application.

Is there a way to do this? Also, eventually, the project will be broken
into smaller projects such as a business tier and data access tier and I
will want to have these types referenced as described above throughout the
entire solution across projects.

any recomendations?

Thanks.


--
mo*******@nospam.com

Nov 21 '05 #5
Thanks to all that replied. Using a source file sounds like a good way to
go. I never thought of that before. How do I use a source file? does it
need to have a particular file extension on it? Any instructions would be
great.

Thanks!

--
mo*******@nospam.com
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:OM**************@TK2MSFTNGP12.phx.gbl...
Carlos (& moondaddy),
I want to create a public enum that can be used throughout a project. I
created an enum like this in a module: The default for Modules are Friend, which (more then likely) means that
moondaddy has something like:

Module SomeModule
Public Enum ParentType ... End Enum
End Module

Which causes the error. As Herfried suggests, do not put Enums in a
Module, simply put them in a source file.
Public Enum ParentType ... End Enum


Friend Module SomeModule

End Module

moondaddy,
Structures, Enums & Delegates can all be put in their own source files,
they do not need to be contained directly within Module statements.

Hope this helps
Jay

"Carlos J. Quintero [.NET MVP]" <ca*****@NOSPAMsogecable.com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
There is something wrong in your post, because if the ParentType enum is
declared as Public as you state, it works fine. Only if you change its
scope to Friend you get that error.

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
"moondaddy" <mo*******@nospam.com> escribió en el mensaje
news:uH**************@TK2MSFTNGP14.phx.gbl...
I want to create a public enum that can be used throughout a project. I
created an enum like this in a module:

Public Enum ParentType
Project = 0
Stage = 1
VIP = 2
Func = 3
Equipment = 4
Idea = 5
Tech = 6
End Enum

I have been able to declare private variables as ParentType and pass
them as parameters from method to method OK. Now I need to create a
public property in a class as ParentType like this:
Private miCurrentParentType As ParentType

Public Property CurrentParentType() As ParentType
Get
Return miCurrentParentType
End Get
Set(ByVal Value As ParentType)
miCurrentParentType = Value
End Set
End Property

I get a blue squiggly under ParentType in the line:
Public Property CurrentParentType() As ParentType

and the compile error is:
'CurrentParentType' cannot expose a Friend type outside of the Public
class 'Tech_UIL'.

I often have similar problems where I have a public enum or structure
and want to declare variables as these types and pass or reference them
around the application.

Is there a way to do this? Also, eventually, the project will be broken
into smaller projects such as a business tier and data access tier and I
will want to have these types referenced as described above throughout
the entire solution across projects.

any recomendations?

Thanks.


--
mo*******@nospam.com



Nov 21 '05 #6
Moondaddy,
How do I use a source file? I normally add a Class or Module to my project then change the Class or
Module definition to Structure or Enum, which ever one I needed.

For example:
1. Add a new Module called "ParentType", giving a .vb file with:

Module ParentType

End Module

2. Change Module to Enum

Public Enum ParentType
...
End Enum

Most of the time I try to limit one type (Class, Module, Structure, Enum) to
a file, however I will include Enums & Delegates in with other types that
they are closely related to.
does it need to have a particular file extension on it? All source files in VB.NET use the .vb extension.

Hope this helps
Jay

"moondaddy" <mo*******@nospam.com> wrote in message
news:u%***************@TK2MSFTNGP10.phx.gbl... Thanks to all that replied. Using a source file sounds like a good way to
go. I never thought of that before. How do I use a source file? does it
need to have a particular file extension on it? Any instructions would be
great.

Thanks!

--
mo*******@nospam.com
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:OM**************@TK2MSFTNGP12.phx.gbl...
Carlos (& moondaddy),
I want to create a public enum that can be used throughout a project. I
created an enum like this in a module:

The default for Modules are Friend, which (more then likely) means that
moondaddy has something like:

Module SomeModule
Public Enum ParentType

...
End Enum


End Module

Which causes the error. As Herfried suggests, do not put Enums in a
Module, simply put them in a source file.
Public Enum ParentType

...
End Enum


Friend Module SomeModule

End Module

moondaddy,
Structures, Enums & Delegates can all be put in their own source files,
they do not need to be contained directly within Module statements.

Hope this helps
Jay

"Carlos J. Quintero [.NET MVP]" <ca*****@NOSPAMsogecable.com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
There is something wrong in your post, because if the ParentType enum is
declared as Public as you state, it works fine. Only if you change its
scope to Friend you get that error.

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
"moondaddy" <mo*******@nospam.com> escribió en el mensaje
news:uH**************@TK2MSFTNGP14.phx.gbl...
I want to create a public enum that can be used throughout a project. I
created an enum like this in a module:

Public Enum ParentType
Project = 0
Stage = 1
VIP = 2
Func = 3
Equipment = 4
Idea = 5
Tech = 6
End Enum

I have been able to declare private variables as ParentType and pass
them as parameters from method to method OK. Now I need to create a
public property in a class as ParentType like this:
Private miCurrentParentType As ParentType

Public Property CurrentParentType() As ParentType
Get
Return miCurrentParentType
End Get
Set(ByVal Value As ParentType)
miCurrentParentType = Value
End Set
End Property

I get a blue squiggly under ParentType in the line:
Public Property CurrentParentType() As ParentType

and the compile error is:
'CurrentParentType' cannot expose a Friend type outside of the Public
class 'Tech_UIL'.

I often have similar problems where I have a public enum or structure
and want to declare variables as these types and pass or reference them
around the application.

Is there a way to do this? Also, eventually, the project will be
broken into smaller projects such as a business tier and data access
tier and I will want to have these types referenced as described above
throughout the entire solution across projects.

any recomendations?

Thanks.


--
mo*******@nospam.com



Nov 21 '05 #7
Thanks that works total great! Can you refer any documention on other good
ways to use source files?

--
mo*******@nospam.com
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:O7**************@TK2MSFTNGP12.phx.gbl...
Moondaddy,
How do I use a source file?

I normally add a Class or Module to my project then change the Class or
Module definition to Structure or Enum, which ever one I needed.

For example:
1. Add a new Module called "ParentType", giving a .vb file with:

Module ParentType

End Module

2. Change Module to Enum

Public Enum ParentType
...
End Enum

Most of the time I try to limit one type (Class, Module, Structure, Enum)
to a file, however I will include Enums & Delegates in with other types
that they are closely related to.
does it need to have a particular file extension on it?

All source files in VB.NET use the .vb extension.

Hope this helps
Jay

"moondaddy" <mo*******@nospam.com> wrote in message
news:u%***************@TK2MSFTNGP10.phx.gbl...
Thanks to all that replied. Using a source file sounds like a good way
to go. I never thought of that before. How do I use a source file?
does it need to have a particular file extension on it? Any instructions
would be great.

Thanks!

--
mo*******@nospam.com
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:OM**************@TK2MSFTNGP12.phx.gbl...
Carlos (& moondaddy),
>I want to create a public enum that can be used throughout a project.
>I created an enum like this in a module:
The default for Modules are Friend, which (more then likely) means that
moondaddy has something like:

Module SomeModule

> Public Enum ParentType
...
> End Enum

End Module

Which causes the error. As Herfried suggests, do not put Enums in a
Module, simply put them in a source file.

> Public Enum ParentType
...
> End Enum

Friend Module SomeModule

End Module

moondaddy,
Structures, Enums & Delegates can all be put in their own source files,
they do not need to be contained directly within Module statements.

Hope this helps
Jay

"Carlos J. Quintero [.NET MVP]" <ca*****@NOSPAMsogecable.com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
There is something wrong in your post, because if the ParentType enum
is declared as Public as you state, it works fine. Only if you change
its scope to Friend you get that error.

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
"moondaddy" <mo*******@nospam.com> escribió en el mensaje
news:uH**************@TK2MSFTNGP14.phx.gbl...
>I want to create a public enum that can be used throughout a project.
>I created an enum like this in a module:
>
> Public Enum ParentType
> Project = 0
> Stage = 1
> VIP = 2
> Func = 3
> Equipment = 4
> Idea = 5
> Tech = 6
> End Enum
>
> I have been able to declare private variables as ParentType and pass
> them as parameters from method to method OK. Now I need to create a
> public property in a class as ParentType like this:
>
>
> Private miCurrentParentType As ParentType
>
> Public Property CurrentParentType() As ParentType
> Get
> Return miCurrentParentType
> End Get
> Set(ByVal Value As ParentType)
> miCurrentParentType = Value
> End Set
> End Property
>
> I get a blue squiggly under ParentType in the line:
> Public Property CurrentParentType() As ParentType
>
> and the compile error is:
> 'CurrentParentType' cannot expose a Friend type outside of the Public
> class 'Tech_UIL'.
>
> I often have similar problems where I have a public enum or structure
> and want to declare variables as these types and pass or reference
> them around the application.
>
> Is there a way to do this? Also, eventually, the project will be
> broken into smaller projects such as a business tier and data access
> tier and I will want to have these types referenced as described above
> throughout the entire solution across projects.
>
> any recomendations?
>
> Thanks.
>
>
>
>
> --
> mo*******@nospam.com
>



Nov 21 '05 #8

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

Similar topics

7
by: Ben Thomas | last post by:
Hi all, I'm having some trouble understanding the behavior of std::ostringstream. (I'm using Visual Studio .Net & STL port 4.5.3). I'll appreciate if someone can give me a little explanation of...
3
by: Mr. Clean | last post by:
Very new to XML style sheets and need some help getting this XML: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE CDSLogger SYSTEM "CDSLogger.dtd"> <CDSLogger> <ErrorObject> <BatchName>This...
6
by: pembed2003 | last post by:
Hi all, I am reading the book "C++ How to Program" and in the chapter where it discuss scope rule, it says there are four scopes for a variable: function scope file scope block scope...
15
by: drdoubt | last post by:
using namespace std In my C++ program, even after applying , I need to use the std namespace with the scope resolution operator, like, std::cout, std::vector. This I found a little bit...
1
by: bin_P19 P | last post by:
the code i have got is as follows and now im stuck <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Shopping...
8
by: SAN CAZIANO | last post by:
i have to do in the onkeypress or in onchange the float (real) field validation I try something: function ValidaCampo(nomeCampo,TotInteri,TotDecimali) {...
8
by: Robert | last post by:
Hi, I can use "with" like this: function MyObject(message) { this.message = message; } function _MyObject_speak() {
106
by: xtra | last post by:
Hi Folk I have about 1000 procedures in my project. Many, many of them are along the lines of function myfuntion () as boolean on error goto er '- Dim Dbs as dao.database Dim Rst as...
2
by: Jon Davis | last post by:
The garbage handler in the .NET framework is handy. When objects fall out of scope, they are automatically destroyed, and the programmer doesn't have to worry about deallocating the memory space...
1
by: Jeff | last post by:
I have located the following code and trying to change this so I know if the USB device has been inserted or removed. The problem I have is I alwayd get the Console.WriteLine("Usb removed") so I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.