problem concatenating two strings to create an enum value

I have the following enum:
 Public Enum enmAvailabilityMonths              
        October08 = 1
        November08 = 2
        December08 = 3
        January09 = 4
        February09 = 5
        March09 = 6
        April09 = 7
        May09 = 8
        June09 = 9
        July09 = 10
        August09 = 11
        September09 = 12
    End Enum

In one of my functions which expects this enum i am trying to concatenate two strings to produce say the value October08 like so:

Dim month As String = GetFullMonthValue(e.Day.Date.Month)
        Dim year As String = e.Day.Date.Year.ToString.Substring(2, 2)

        RenderDay(e, CType(month & year, UKCaravanFinderUtils.enmAvailabilityMonths), cldDisplay, e.Day.Date.Year, e.Day.Date.Month)

I then try converting the value to type UKCaravanFinderUtils.enmAvailabilityMonths.

I am getting the error cannot convert my string to integer based on this value.

Is there a workaround?
scm0smlAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DhaestCommented:
Can you try this:

Dim myDate as enmAvailabilityMonths = (enmAvailabilityMonths )(month & year)
RenderDay(e, CType(myDate, UKCaravanFinderUtils.enmAvailabilityMonths), cldDisplay, e.Day.Date.Year, e.Day.Date.Month)
0
scm0smlAuthor Commented:
doesnt like this line:
Dim myDate As enmAvailabilityMonths = (enmAvailabilityMonths)(month & year)

(enmAvailabilityMonths)  is a type and cannot be used as an expression?
0
DhaestCommented:
The solution you need is to convert your string to an enum-value through casting. Perhaps with the previous post I'v posted c# code (combined with vb.net).
Can you try this cast
Dim myDate  As enmAvailabilityMonths= DirectCast([Enum].Parse(GetType(enmAvailabilityMonths), Montth & Year,True), enmAvailabilityMonths)

Otherwise check the following
dim myDate as string = Month & Year
--> what is the value of myDate ? Make sure that its like your enumvalue
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
scm0smlAuthor Commented:
Dim myDate As enmAvailabilityMonths = DirectCast([Enum].Parse(GetType(enmAvailabilityMonths), month & year, True), enmAvailabilityMonths)

worked a treat.

thanks for that!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.