Results 1 to 4 of 4

Thread: Public Enum not accessible in class

  1. #1

    Thread Starter
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Public Enum not accessible in class

    I've declared an Enum in a module called Globals as follows:

    VB Code:
    1. Public Enum PowerSupplies As Integer
    2.         Remote
    3.         Panel5V
    4.         Panel24V
    5.     End Enum

    I'm trying to use this in a property in a public class (called 'CANN' as follows:

    VB Code:
    1. Public Property PowerSupply() As PowerSupplies
    2.         Get
    3.  
    4.             Return mPowerSupply
    5.         End Get
    6.         Set(ByVal PowerSupply As PowerSupplies)
    7.             mPowerSupply = PowerSupply
    8.         End Set
    9.  
    10.     End Property

    I get an error - "'PowerSupply cannot expose a Friend type outside of the public class 'CANN'".

    Does anyone have any idea why this doesn't work for me? If I declare the Enum inside the class it's fine, but it doesn't seem to work with it declared (even as Public) in another module.
    This world is not my home. I'm just passing through.

  2. #2
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    If you leave out the "access" keyword for a module its declared friend. Try

    Public Module Test
    'enum
    End Module

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    worked well when I added this line :
    VB Code:
    1. Public mPowerSupply As PowerSupplies

    without runtimes error.!!!!
    Friend Scope is just like Public except it's not available outside your assembly.

  4. #4

    Thread Starter
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    Problem solved!

    Thanks to Pirate and the flower-filled hat (Athley).
    This world is not my home. I'm just passing through.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width