Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Losing Module Level ENums in Excel 2003

This is driving me crazy!

I have a bunch of constants and Private Enums declared at the top of my
regular module.

e.g.
(I've paired this down for brevity.)

Private Const mcstrDataWorksheetName As String = "DataSheet"
Private mstrArray() as String
Private Enum eStageName
LBoundIndex = 1&
Text = 1&
DatabaseName = 2&
DisplayName = 3&
UBoundIndex = 3&
End Enum

Private Enum ePropertyIndex
LBoundIndex = 1&
Text = 1&
DisplayName = 2&
DefaultValue = 3&
Unit = 4&
UBoundIndex = 4&
End Enum

I use them like

Dim mstrArray(ePropertyIndex.LBoundIndex To ePropertyIndex.UBoundIndex)

Everything have been working fine for several weeks ... except
Every now and then, the Enums stop working! It's always after some
debugging, trying things, making some mistakes, and then, making some change
in a section of code that is seemingly unrelated to Enums, the next time I
try and run the program I get the following:

Microsoft Visual Basic
Compile Error:
Constant expression required.

And it goes to the first spot in my LoadObjects routine that uses an Enum,
with the member highlighted. (the Dot and DisplayName are highlighted)

ePropertyIndex.DisplayName

NOTE: Commenting out the line simply moves the error to the next Enum. If I
comment out every enum used in the Sub, it will recognize other module level
variables and constants. But will give me the same compile error whenever it
runs across the next Enum. I comment out everything I was just changing and
it won't run.

Sometimes, restarting Excel "fixes" the problem, sometimes rebooting the box
"fixes" the problem, other times, it just refuses to work and at what seems
like an arbitrary time in the future, it works again.

Anybody got any ideas?

TIA, Bob
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Losing Module Level ENums in Excel 2003

FWIW, this seems to be working ...

Comment out all enums.
Compile under the Debug Menu, let it fail.
Uncomment the enums, Recompile

I don't understand it, but this heuristic has worked every time so far.

Bob


"INTP56" wrote:

This is driving me crazy!

I have a bunch of constants and Private Enums declared at the top of my
regular module.

e.g.
(I've paired this down for brevity.)

Private Const mcstrDataWorksheetName As String = "DataSheet"
Private mstrArray() as String
Private Enum eStageName
LBoundIndex = 1&
Text = 1&
DatabaseName = 2&
DisplayName = 3&
UBoundIndex = 3&
End Enum

Private Enum ePropertyIndex
LBoundIndex = 1&
Text = 1&
DisplayName = 2&
DefaultValue = 3&
Unit = 4&
UBoundIndex = 4&
End Enum

I use them like

Dim mstrArray(ePropertyIndex.LBoundIndex To ePropertyIndex.UBoundIndex)

Everything have been working fine for several weeks ... except
Every now and then, the Enums stop working! It's always after some
debugging, trying things, making some mistakes, and then, making some change
in a section of code that is seemingly unrelated to Enums, the next time I
try and run the program I get the following:

Microsoft Visual Basic
Compile Error:
Constant expression required.

And it goes to the first spot in my LoadObjects routine that uses an Enum,
with the member highlighted. (the Dot and DisplayName are highlighted)

ePropertyIndex.DisplayName

NOTE: Commenting out the line simply moves the error to the next Enum. If I
comment out every enum used in the Sub, it will recognize other module level
variables and constants. But will give me the same compile error whenever it
runs across the next Enum. I comment out everything I was just changing and
it won't run.

Sometimes, restarting Excel "fixes" the problem, sometimes rebooting the box
"fixes" the problem, other times, it just refuses to work and at what seems
like an arbitrary time in the future, it works again.

Anybody got any ideas?

TIA, Bob

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
Where to declare module-level variables? Ed from AZ Excel Programming 5 August 21st 07 01:27 AM
Set objects at module level? Ed Excel Programming 3 May 8th 07 07:15 AM
use of module level variables TxRaistlin Excel Programming 2 March 3rd 05 10:41 PM
referencing at module level Mark[_36_] Excel Programming 1 March 1st 04 01:24 PM
module-level variable lifetime Jessie[_2_] Excel Programming 0 July 30th 03 09:31 PM


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

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

About Us

"It's about Microsoft Excel"