Thread
:
Return value of Property Get when using enumerated type
View Single Post
#
4
Posted to microsoft.public.excel.programming
jason
external usenet poster
Posts: 104
Return value of Property Get when using enumerated type - HELP!!
cheers Jamie - that extra prperty is the approach i've ended up taking.
Jason
(Jamie Collins) wrote in message . com...
(jason) wrote ...
In a class module named PlayingCard I have:
public enum enumColour
CdRed = 1
CdBlack = 2
end enum
private mColour as string
property let CardColour(byval clntColour as enumcolour)
select case clntColour
case CdRed,CdBlack
mColour = clntColour
case else
'error trapping goes heer
end select
end property
property get CardColour() as enumColour
CardColour = mColour
end property
Then in a standard module:
dim NewCard as PlayingCard
Sub CheckitOut
set NewCard = new PlayingCard
With NewCard
.cardcolour = CdRed
end with
debug.print "The Cards colour: " & newcard.cardcolour
end sub
What I'm left with in the immediate window is:
The Cards colour: 1
But what I want returned in the immediate window is
The Cards colour: CdRed
A similar problem: how do you print the name of a variable?
Debug.Print <variable name will print its value but what about its
name, surely it knows its own name?!
You will need another property:
public property get CardColourText() as string
CardColourText = GetCardColourText(mColour)
end property
Private function GetCardColourText( _
byval Colour as enumcolour _
) as String
dim sReturn as string
select case Colour
case CdRed
sReturn = "Red"
case CdBlack
sReturn = "Black"
case else
' error trapping goes here
end select
GetCardColourText = sReturn
end function
Jamie.
--
Reply With Quote
jason
View Public Profile
Find all posts by jason