Reputation: 1157
I don't really know how to explain this correctly, so I will try to be as simple as possible.
When you create a Boolean variable (for example) you get a little popup menu allowing you to chose either True or False.
Is there a way of creating a custom property that when referenced, gives a custom list of selectable options?
For example, I want to create a new property called Car_Model that gave users a selectable list of car makes (e.g. Holden, Ford, Chevy, Etc.) So using the property would be something like:
Dim _car as Car = New Car
Car.Car_Model = {Popup a list of selectable options here, e.g. Model.Holden, Model.Ford, Model.Chevy, etc.}
Car.Name = "Betsy"
...
So far I've only really worked with property types within a class, but I guess it's somehow related to creating my own 'Type'. So instead of String or Boolean it would be a Car_Model.
Hope that makes sense. Thanks
Upvotes: 0
Views: 567
Reputation:
Use an Enum
Public Enum Car_Model
none = 0
Mazda
Chevy
Ford
End Enum
Upvotes: 1
Reputation: 6375
What you want is an Enumeration. You define it like this:
Public Enum CarModel
BMW = 1
Porsche = 2
Audi = 3
Ferrari = 4
End Enum
You can then define a variable of this type
Dim Model As CarModel = CarModel.Porsche
The enumeration can be understood as named integer variables. So you basically can also assign the respective number to the variable. Assigning values to the enumeration elements is not strictly needed and further properties can be defined using attributes. See MSDN for further details:
http://msdn.microsoft.com/en-us/library/8h84wky1.aspx
Upvotes: 0