Enum

D

Daniel

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
 
P

Paul Reynolds

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top