Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'd like to create a property which can only have a few flags.

 
  Dim _stat As Integer
  Enum status As Integer
       DefaultStatus = 0
       NotConnected = 1
       Running = 2
       Stopped = 3
       Paused = 4
   End Enum

 

   Private Property ChangeStatus() As Integer
       Get
           Return _stat
       End Get
       Set(ByVal ValueAs Integer)
           _stat = Value
       End Set
   End Property

 

How can I achieve that you can only change to predefined status values?

 

tx

 

matej

Posted

Change the type of the property to the name of you Enum...

   Private Property ChangeStatus() As Status
       Get
           Return _stat
       End Get
       Set(ByVal ValueAs Integer)
           _stat = Value
       End Set
   End Property 

 

Also, you don't need to type the Enum as an Integer. The default type is integer.. Further, Enums can only be of type Byte, Integer, Long, or Short.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...