scm0sml
asked on
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.Da te.Month)
Dim year As String = e.Day.Date.Year.ToString.S ubstring(2 , 2)
RenderDay(e, CType(month & year, UKCaravanFinderUtils.enmAv ailability Months), cldDisplay, e.Day.Date.Year, e.Day.Date.Month)
I then try converting the value to type UKCaravanFinderUtils.enmAv ailability Months.
I am getting the error cannot convert my string to integer based on this value.
Is there a workaround?
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.Da
Dim year As String = e.Day.Date.Year.ToString.S
RenderDay(e, CType(month & year, UKCaravanFinderUtils.enmAv
I then try converting the value to type UKCaravanFinderUtils.enmAv
I am getting the error cannot convert my string to integer based on this value.
Is there a workaround?
ASKER
doesnt like this line:
Dim myDate As enmAvailabilityMonths = (enmAvailabilityMonths)(mo nth & year)
(enmAvailabilityMonths) is a type and cannot be used as an expression?
Dim myDate As enmAvailabilityMonths = (enmAvailabilityMonths)(mo
(enmAvailabilityMonths) is a type and cannot be used as an expression?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dim myDate As enmAvailabilityMonths = DirectCast([Enum].Parse(Ge tType(enmA vailabilit yMonths), month & year, True), enmAvailabilityMonths)
worked a treat.
thanks for that!
worked a treat.
thanks for that!
Dim myDate as enmAvailabilityMonths = (enmAvailabilityMonths )(month & year)
RenderDay(e, CType(myDate, UKCaravanFinderUtils.enmAv