#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default 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






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Enum in Excel 97 Rob Bovey Excel Programming 0 September 26th 03 11:02 PM
Enum in Excel 97 Chip Pearson Excel Programming 0 September 26th 03 10:03 PM


All times are GMT +1. The time now is 09:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"