﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » .NET Forums » General .NET Discussion  » An Enum question</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Wed, 10 Jun 2026 20:35:24 GMT</lastBuildDate><ttl>20</ttl><item><title>An Enum question</title><link>http://forum.strataframe.net/FindPost5232.aspx</link><description>Here is the error i'm getting:&lt;P&gt;[b]'ParentFormID' cannot expose type 'Module1.ParentFormIDEnum' outside the project through class 'MyClass'.[/b]&lt;/P&gt;&lt;P&gt;Here is the related code:&lt;/P&gt;&lt;P&gt;[codesnippet]Module&amp;nbsp;Module1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Enum ParentFormIDEnum As Integer&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; POReceiving = 1&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Production = 4&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Returns = 5&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Enum&lt;/P&gt;&lt;P&gt;End Module&lt;BR&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;[codesnippet]Public Class MyClass&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public WriteOnly Property ParentFormID() As ParentFormIDEnum&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set(ByVal value As ParentFormIDEnum)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; miParentFormID = value&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Set&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Property&lt;/P&gt;&lt;P&gt;End Class&lt;BR&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;I'm not sure what this error means. All I'm trying to do is create a global enum and be able to use it in all areas of my program.</description><pubDate>Thu, 04 Jan 2007 22:16:51 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: An Enum question</title><link>http://forum.strataframe.net/FindPost5595.aspx</link><description>Anything for you, Ivan :D</description><pubDate>Thu, 04 Jan 2007 22:16:51 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: An Enum question</title><link>http://forum.strataframe.net/FindPost5593.aspx</link><description>Thanks guys, got the idea.</description><pubDate>Thu, 04 Jan 2007 19:18:33 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: An Enum question</title><link>http://forum.strataframe.net/FindPost5591.aspx</link><description>No, Ivan, you can have as many Imports as you want... they don't affect the runtime whatsoever.&amp;nbsp; They're more compiler directives than anything.</description><pubDate>Thu, 04 Jan 2007 17:51:33 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: An Enum question</title><link>http://forum.strataframe.net/FindPost5590.aspx</link><description>Not necessarily.&amp;nbsp; But keep in mind that you can create multiple sealed classes as well.&amp;nbsp; It is best to keep things that are related within a single class.&amp;nbsp;</description><pubDate>Thu, 04 Jan 2007 17:48:25 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: An Enum question</title><link>http://forum.strataframe.net/FindPost5589.aspx</link><description>[quote][b]Ben Chase (12/12/2006)[/b][hr]Basically, a "sealed" class is what you use in VB to be a container for methods.[/quote]&lt;P&gt;Hiya.&lt;P&gt;Having a sealed class being a container for methods, I might need to write many "Imports" on the top of it for all the methods that will be in the class. &lt;P&gt;Would this be a bad practice?</description><pubDate>Thu, 04 Jan 2007 17:43:50 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: An Enum question</title><link>http://forum.strataframe.net/FindPost5266.aspx</link><description>You can have as many classes in a file as you want... you can even have nested classes.&amp;nbsp; Basically, with VB.NET, you can have a 1 file to 1 class relationship, or you can have a multiple file to 1 class relationship (partial classes... part of the class exists in each file), or you can have a 1 file to multiple class relationship.&amp;nbsp; The code file does not define a class... the Public Class &amp;lt;ClassName&amp;gt; and End Class do.&amp;nbsp; Open up one of the .designer.vb files for one of your business objects and drop down the left combo box at the top of the file... you'll see how many classes exist in that one file.&amp;nbsp; And besides the business object, they're all nested.</description><pubDate>Wed, 13 Dec 2006 08:21:05 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: An Enum question</title><link>http://forum.strataframe.net/FindPost5261.aspx</link><description>And here's where my VB6 brain &lt;IMG title=Hehe src="http://forum.strataframe.net/Skins/Classic/Images/EmotIcons/Hehe.gif" align=absMiddle border=0&gt;&amp;nbsp;is having trouble... I dont understand how I can place the enum 'outside' of the Module. &lt;P&gt;I've seen examples like this:&lt;/P&gt;&lt;P&gt;[codesnippet]Public Class Item&lt;/P&gt;&lt;P&gt;End Class&lt;/P&gt;&lt;P&gt;Public Class Inventory&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim itm as new Item&lt;/P&gt;&lt;P&gt;End Class[/codesnippet]&lt;/P&gt;&lt;P&gt;I dont understand how you can have two classes in the same file. I am under the impression that you can only have one class per file.&amp;nbsp; What gives? :P&lt;P&gt;P.S. I really appreciate this thread and the advice on using a shared class instead of a module... that is invaluable information that I might not otherwise pickup. :cool:</description><pubDate>Wed, 13 Dec 2006 07:38:09 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: An Enum question</title><link>http://forum.strataframe.net/FindPost5246.aspx</link><description>Awesome! Thanks for the info.</description><pubDate>Tue, 12 Dec 2006 16:31:11 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: An Enum question</title><link>http://forum.strataframe.net/FindPost5245.aspx</link><description>Basically, a "sealed" class is what you use in VB to be a container for methods.&amp;nbsp; (C# has a "static" class, but "sealed" is as close as you can get in VB).&amp;nbsp; You create the class, and it becomes the module (actually, when you compile a module in VB.NET, it creates a class out of the module on the back end.. which you can see if you use reflection).&lt;/P&gt;&lt;P&gt;Public NotInheritable Class MyModuleClass&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- A private&amp;nbsp;constructor keeps someone from accidentally trying to create&amp;nbsp;an instance of this class&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private Sub New()&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- All of your methods and fields are then marked with "Shared"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public Shared Function MyFunc(ByVal value As String) As String&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- Parse the value&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Function&lt;/P&gt;&lt;P&gt;End Class&lt;/P&gt;&lt;P&gt;'-- When you access these Shared methods and fields, you access them like this:&lt;BR&gt;MyModuleClass.MyFunc("test") '-- you use the ClassName. syntax and you get all of the shared methods on the class</description><pubDate>Tue, 12 Dec 2006 16:28:45 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: An Enum question</title><link>http://forum.strataframe.net/FindPost5240.aspx</link><description>Ok, I moved the enums outside of the Module and now it looks like this:&lt;P&gt;[codesnippet]&lt;/P&gt;&lt;P&gt;Public Module Module1&lt;/P&gt;&lt;P&gt;End Module&lt;/P&gt;&lt;P&gt;Public Enum ParentFormIDEnum As Integer&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; POReceiving = 1&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Production = 4&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Returns = 5&lt;BR&gt;End Enum&lt;BR&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;And here's where my VB6 brain :hehe:&amp;nbsp;is having trouble... I dont understand how I can place the enum 'outside' of the Module. When I created the module, it created a Module1.vb file... and inside it was &lt;/P&gt;&lt;P&gt;[codesnippet]&lt;/P&gt;&lt;P&gt;Module Module1&lt;/P&gt;&lt;P&gt;End Module&lt;/P&gt;&lt;P&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;I assumed that everything had to reside inside there, and the only thing allowed outside was the Imports statements at the top.</description><pubDate>Tue, 12 Dec 2006 16:19:25 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: An Enum question</title><link>http://forum.strataframe.net/FindPost5236.aspx</link><description>Lol didnt see Trent already answered you.&amp;nbsp;I agree about modules.&lt;/P&gt;&lt;P&gt;1)&amp;nbsp; If you reference your project from another project, whether VB or C#, the module routines aren't accessible even if they're public.&lt;BR&gt;&lt;BR&gt;2)&amp;nbsp; You can name a local method in a class the same as a public module routine, and the compiler won't say anything about it.&amp;nbsp; When you use the method, the compiler won't require you to prefix it; it'll just happily use the local version instead of the module with no warning.&lt;BR&gt;&lt;BR&gt;Shared classes, on the other hand, are accessible to outside projects (if you want them to be), and shared classes avoid the ambiguity because of the prefixed class name.</description><pubDate>Tue, 12 Dec 2006 15:51:34 GMT</pubDate><dc:creator>Paul Chase</dc:creator></item><item><title>RE: An Enum question</title><link>http://forum.strataframe.net/FindPost5235.aspx</link><description>Thanks Trent. Thanks Paul. &lt;/P&gt;&lt;P&gt;Trent, How is a shared class different from a regular class?</description><pubDate>Tue, 12 Dec 2006 15:49:03 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: An Enum question</title><link>http://forum.strataframe.net/FindPost5234.aspx</link><description>Mike,&lt;/P&gt;&lt;P&gt;Your class is public but the module isn't so it is letting you know that your class is public which exposes the module which is friend. Just make the module public and it should work. Or make the class friend&lt;/P&gt;&lt;P&gt;Public module whatever&lt;/P&gt;&lt;P&gt;Paul</description><pubDate>Tue, 12 Dec 2006 15:44:46 GMT</pubDate><dc:creator>Paul Chase</dc:creator></item><item><title>RE: An Enum question</title><link>http://forum.strataframe.net/FindPost5233.aspx</link><description>Since your enum and module have not been defined as public then you cannot have a public property expose those privately typed classes.&amp;nbsp; You need to add Public in front of Module and your enum.&lt;/P&gt;&lt;P&gt;I do not recommend using modules!&amp;nbsp; This was left for backward compatability.&amp;nbsp; You should use shared classes.&amp;nbsp; In the case of your enum, just move it outside of the module and it will reside as its own public enum:&lt;/P&gt;&lt;P&gt;[codesnippet]Public Enum MyEnum As Integer&lt;BR&gt;&amp;nbsp;&amp;nbsp; MyValue = 1&lt;BR&gt;End Enum[/codesnippet]</description><pubDate>Tue, 12 Dec 2006 15:38:00 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>