ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Enum (https://www.excelbanter.com/excel-programming/285976-enum.html)

Daniel[_4_]

Enum
 
Hello,
Suppose I want to write the following which are strings
If reportingMonth statusMonth Then
....
Since they are strings, the comparaison is not good. However if I add
Enum lesMois
janvier = 1
février = 2
mars = 3
avril = 4
mai = 5
juin = 6
juillet = 7
août = 8
septembre = 9
octobre = 10
novembre = 11
décembre = 12
End Enum

can I do that comparaison and how do I use it so that it refers to the
numerical equivalent?

Thank you for your suggestions.

Daniel



Paul Reynolds[_2_]

Enum
 
An enum won't work for this, as there is no way to use the enum's string
literals. It's better to use a collection, e.g.

Dim cMonths As New Collection

cMonths.Add 1, "janvier"
cMonths.Add 2, "février"
cMonths.Add 3, "mars"
cMonths.Add 4, "avril"
cMonths.Add 5, "mai"
cMonths.Add 6, "juin"
cMonths.Add 7, "juillet"
cMonths.Add 8, "août"
cMonths.Add 9, "septembre"
cMonths.Add 10, "octobre"
cMonths.Add 11, "novembre"
cMonths.Add 12, "décembre"

If cMonths(LCase(reportingMonth)) cMonths(LCase(statusMonth)) Then
...
End If

Hope this helps.

"Daniel" wrote in message
...
Hello,
Suppose I want to write the following which are strings
If reportingMonth statusMonth Then
....
Since they are strings, the comparaison is not good. However if I add
Enum lesMois
janvier = 1
février = 2
mars = 3
avril = 4
mai = 5
juin = 6
juillet = 7
août = 8
septembre = 9
octobre = 10
novembre = 11
décembre = 12
End Enum

can I do that comparaison and how do I use it so that it refers to the
numerical equivalent?

Thank you for your suggestions.

Daniel





Tom Ogilvy

Enum
 
If cdate(ReportingMonth & " 1, 2003") cDate(statusMonth & " 1, 2003") then

--
Regards,
Tom Ogilvy

Daniel wrote in message
...
Hello,
Suppose I want to write the following which are strings
If reportingMonth statusMonth Then
....
Since they are strings, the comparaison is not good. However if I add
Enum lesMois
janvier = 1
février = 2
mars = 3
avril = 4
mai = 5
juin = 6
juillet = 7
août = 8
septembre = 9
octobre = 10
novembre = 11
décembre = 12
End Enum

can I do that comparaison and how do I use it so that it refers to the
numerical equivalent?

Thank you for your suggestions.

Daniel





Daniel[_4_]

Enum
 
Thank you Paul, this is doing the job, perfectly.
_______________
"Paul Reynolds" a écrit dans le message de
...
An enum won't work for this, as there is no way to use the enum's string
literals. It's better to use a collection, e.g.

Dim cMonths As New Collection

cMonths.Add 1, "janvier"
cMonths.Add 2, "février"
cMonths.Add 3, "mars"
cMonths.Add 4, "avril"
cMonths.Add 5, "mai"
cMonths.Add 6, "juin"
cMonths.Add 7, "juillet"
cMonths.Add 8, "août"
cMonths.Add 9, "septembre"
cMonths.Add 10, "octobre"
cMonths.Add 11, "novembre"
cMonths.Add 12, "décembre"

If cMonths(LCase(reportingMonth)) cMonths(LCase(statusMonth)) Then
...
End If

Hope this helps.

"Daniel" wrote in message
...
Hello,
Suppose I want to write the following which are strings
If reportingMonth statusMonth Then
....
Since they are strings, the comparaison is not good. However if I

add
Enum lesMois
janvier = 1
février = 2
mars = 3
avril = 4
mai = 5
juin = 6
juillet = 7
août = 8
septembre = 9
octobre = 10
novembre = 11
décembre = 12
End Enum

can I do that comparaison and how do I use it so that it refers to the
numerical equivalent?

Thank you for your suggestions.

Daniel








All times are GMT +1. The time now is 03:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com