LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default Enum bug?

Hello,

I’m just wondering if anyone else has come across this Enum “quirk”.
Tested on XL2003 & 2010.

Option Explicit

Public Enum List1
nam1 = 11
nam2 = 22
End Enum

Public Enum List2
nam1 = 11
nam3 = 33
End Enum

Scenario 1:
Sub Test ()
Debug.Print nam1
End Sub
Do a compile. I was expecting a “Compile error: Variable not defined”
message, but got “Compile error: Ambiguous name detected: nam1”
message instead.

Scenario 2:
Sub Test()
Debug.Print nam3
End Sub

This did NOT generate a compile error, but printed “33” when executed.

Scenario 3:
Sub Test()
Dim nam3 As Long
nam3 = 99
Debug.Print nam3
End Sub

Of course, this one compiled without error and printed “99” on
execution.

In the past I’ve depended on the compiler to pick up missed
declarations, but it seems this can’t be relied on when Enums are
involved.

Any comments appreciated.

Regards,

Dave U



 
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
Get an enum value assigned Tetsuya Oguma Excel Programming 2 October 21st 08 06:52 AM
Enum Daniel[_4_] Excel Programming 3 December 22nd 03 12:30 AM
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 02:46 PM.

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"