Link to home
Start Free TrialLog in
Avatar of ckanoab
ckanoab

asked on

Default values for a property in a class VB 2005

VB 2005 Express: Is there a way to define default values for a property? Simple example, when you type = after a boolean property, say... visible, it pops up intellisense true and false, is there a way to make custom options in place of true or false?
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Define an Enumeration.

After the equals you would get the list of wet, dry and dirty:

        Dim d As New Dog
        d.MyDogsNose =

Here is the class:

    Private Class Dog

        Public Enum NoseType
            wet
            dry
            dirty
        End Enum

        Private dogNoseType As Dog.NoseType

        Public Property MyDogsNose() As Dog.NoseType
            Get
                Return dogNoseType
            End Get
            Set(ByVal value As Dog.NoseType)
                dogNoseType = value
            End Set
        End Property

    End Class
Avatar of ckanoab
ckanoab

ASKER

And the values of those types? True translates to -1 and such, is that limited to numbers? Can it be a string?
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial