Class module: Pick from a list of possible property values?

DB505050

Registered User.
Local time
Today, 17:11
Joined
Nov 15, 2012
Messages
16
I am having trouble finding anyone discussing this question. In a class module, say I have a property Color.

Class Stuff

Property Get Color() as string
Color = mlColor
End Property

Property Let Color(ByVal NewColor as String)
mlColor = NewColor
End Property

But when I am using this property, this is what I want:

Dim c as Stuff

Set c = New Stuff

c.Color = (Show a list of colors I have defined as constants somewhere)

I don't want a sub-class of color. It is similar to when you are doing a DoCmd.OpenQuery "QueryName", (here there is a dropdown of acViewDesign, acViewLayout, etc.)

Is this possible in user-defined classes? I really appreciate any help!
 
Just curious how you plan to use this - ?
 
Never ran across the enum thing - thanks Galax

hum... now where could have I have used that - :)
 
Post #6 in this thread shows the power of Enum in a class that would be quite clumsy to use without it.
 
Just curious how you plan to use this - ?

I appreciate any direction you can give me, if I am thinking about this the wrong way. I have something like this in my class module:

Class ODBCServer

Property Get Value() As String
.... etc.

So, this is what I want to happen when I instantiate ODBCServer, and choose the Value property:

ODBCServer.Value = (Drop-down of Server 'constants')

This corresponds to an ODBC database server that we access through pass-through queries. There are 3 servers (currently) that I want to show up if someone initializes the object for this server. So when they do ODBCServer.Value =, I want a drop-down to show up of those 3 server constants.

The problem with enum is that it is only for numbers. All I want is to have 3 constants "tied" to this property (ODBCServer.Value), so they will show up as possible choices.

Again, please let me know if there is a better way of thinking about this. I am new to OOP.
 
I really don't understand whats goig on but it seems you could just store these in a table
 

Users who are viewing this thread

Back
Top Bottom